-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathparent_handler_test.py
48 lines (41 loc) · 1.27 KB
/
parent_handler_test.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
import bpy, time
from bpy.app.handlers import persistent
def act_strip(context):
try:
return context.scene.sequence_editor.active_strip
except AttributeError:
return None
def find_parent(child):
if (type(child) == str):
childname = child
else:
childname = child.name
scene = bpy.context.scene
for relationship in scene.parenting:
if (relationship.child == childname):
return relationship.parent
return "None"
def find_children(parent):
if (type(parent) == str):
parentname = parent
else:
parentname = parent.name
scene = bpy.context.scene
childrennames = []
for relationship in scene.parenting:
if (relationship.parent == parentname):
childrennames.append(relationship.child)
return childrennames
@persistent
def load_handler(dummy):
scn = bpy.context.scene
strips = scn.sequence_editor.sequences_all
strip = act_strip(bpy.context)
if scn.parenting:
childrennames = find_children(strip.name)
parentname = find_parent(strip.name)
print(childrennames)
for i in strips:
if i.name in childrennames:
i.select = True
bpy.app.handlers.scene_update_post.append(load_handler)