-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
79 lines (55 loc) · 1.89 KB
/
utils.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
70
71
72
73
74
75
76
77
78
79
import bpy
OBJNAME_COLLIDER = 'STRA_COLLIDER'
OBJNAME_JOINT = 'STRA_JOINT'
def get_collection(parent_col, name, create=True):
col = parent_col.children.get(name)
if col is None and create:
col = bpy.data.collections.new(name)
parent_col.children.link(col)
col.color_tag = 'COLOR_04'
return col
def get_collection_temp(create=True):
col_parent = get_collection(bpy.context.scene.collection, 'STRUCTURA', create=create)
col = get_collection(col_parent, 'STRUCTURA_TEMP', create=create)
return col
def clear_temp_collection():
col = get_collection_temp()
for obj in col.objects:
bpy.data.objects.remove(obj)
def get_collection_joints(create=True):
col_parent = get_collection(bpy.context.scene.collection, 'STRUCTURA', create=create)
if col_parent is None:
return None
col = get_collection(col_parent, 'STRUCTURA_JOINTS', create=create)
if col is None:
return None
return col
def get_collection_colliders(create=True):
col_parent = get_collection(bpy.context.scene.collection, 'STRUCTURA', create=create)
if col_parent is None:
return None
col = get_collection(col_parent, 'STRUCTURA_COLLIDERS', create=create)
if col is None:
return None
for ob in col.objects:
if ob.parent is None:
for cl in ob.users_collection:
cl.objects.unlink(ob)
if create:
col.hide_select = True
col.hide_render = True
return col
def draw_list_entry(b, left, right):
r = b.row()
r.scale_y = 0.7
c1 = r.column()
c1.alignment = 'LEFT'
c1.label(text=f'{left}')
c2 = r.column()
c2.alignment = 'RIGHT'
c2.label(text=f'{right}')
def remove_joint_from_property(ob, joint_name):
if "joints" not in ob:
return
new_joints = [name for name in ob["joints"] if name != joint_name]
ob["joints"] = new_joints