-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRAT_OT_Set_Keyframe_Value.py
More file actions
65 lines (49 loc) · 1.79 KB
/
RAT_OT_Set_Keyframe_Value.py
File metadata and controls
65 lines (49 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import bpy
from bpy.props import FloatProperty
class RAT_OT_Set_Keyframe_Value(bpy.types.Operator):
bl_idname = "object.set_keyframe_value"
bl_label = "Set Keyframe Value"
bl_options = {'REGISTER', 'UNDO'}
my_float_y : FloatProperty(
name="Value",
description="New value for the selected keyframes.",
# get = active_frame_value
# set = seleced_frames__new_value
)
def cpoints(self, context):
ctrl_pts = []
for c in context.selected_visible_fcurves:
for k in c.keyframe_points:
if k.select_control_point:
ctrl_pts.append(k)
return ctrl_pts
@classmethod
def poll(cls, context):
areas = ('DOPESHEET_EDITOR', 'GRAPH_EDITOR', 'TIMELINE')
if context.area.type in areas:
return True
else:
return False
def invoke(self, context, event):
wm = context.window_manager
# return wm.invoke_popup(self, width=100)
return wm.invoke_props_dialog(self, width=100)
# voir https://media.discordapp.net/attachments/456165231945842688/657525317593989120/unknown.png?width=1025&height=193
def execute(self, context):
sel = self.cpoints(context)
for k in sel:
k.co = (k.co.x, self.my_float_y)
k.handle_left = (k.handle_left.x, self.my_float_y)
k.handle_right = (k.handle_left.y, self.my_float_y)
return {'FINISHED'}
def draw(self, context):
lay = self.layout
lay.row().prop(self, "my_float_y")
def register():
bpy.utils.register_class(RAT_OT_Set_Keyframe_Value)
def unregister():
bpy.utils.unregister_class(RAT_OT_Set_Keyframe_Value)
if __name__ == "__main__":
register()
# test call
# bpy.ops.object.simple_operator()