-
Notifications
You must be signed in to change notification settings - Fork 0
/
operators.py
69 lines (48 loc) · 1.76 KB
/
operators.py
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
66
67
68
69
class ShotsDBInit(bpy.types.Operator):
bl_idname = "shots.dbinit"
bl_label = "Initialize Actions DB"
def __init__(self):
self.has_run = False
def execute(self, context):
buddy.db_load()
self.has_run = True
return {'FINISHED'}
class ShotsUnassignAction(bpy.types.Operator):
bl_idname = "shots.unassign_action"
bl_label = "Unassign an action from an object"
object_name: bpy.props.StringProperty(name="obj_name")
def execute(self, context):
buddy.unassign_object_action(self.object_name)
obj = bpy.data.objects[self.object_name]
obj.animation_data_clear()
return {'FINISHED'}
class ShotsAssignAction(bpy.types.Operator):
bl_idname = "shots.assign_action"
bl_label = "Assign an action to an object"
action_name: bpy.props.StringProperty(name="act_name")
new_mom: bpy.props.StringProperty()
@classmethod
def poll(cls, context):
return True
def draw(self, context):
row = self.layout
row.label(text="Assign action to...?")
row = self.layout
row.prop_search(self, "new_mom", bpy.data, "objects")
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def execute(self, context):
buddy.set_move(self.new_mom, self.action_name)
bpy.data.objects[self.new_mom].animation_data.action = bpy.data.actions[self.action_name]
print(self.new_mom + " " + self.action_name)
return {'FINISHED'}
class ShotsToggleVisible(bpy.types.Operator):
bl_idname = "shots.toggle_visible"
bl_label = "Change action visibility"
action_name: bpy.props.StringProperty()
object_name: bpy.props.StringProperty()
def execute(self, context):
state = buddy.toggle_visible(self.action_name, self.object_name)
print(state)
# print (self.action_name + " " + self.object_name)
return {'FINISHED'}