Array children are now transforme-locked after editing the array

I have yet to find how to set it on ifc load though
This commit is contained in:
Gorgious
2023-07-23 13:39:52 +02:00
parent 1468b7fddd
commit c3323733a7
2 changed files with 9 additions and 0 deletions
@@ -135,6 +135,7 @@ class EditArray(bpy.types.Operator, tool.Ifc.Operator):
data = json.dumps(data)
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={"Data": data})
tool.Blender.Modifier.Array.lock_children_transform(element, True)
tool.Blender.Modifier.Array.constrain_children_to_parent(element)
return {"FINISHED"}
@@ -532,6 +532,14 @@ class Blender:
) or child.constraints.new("CHILD_OF")
constraint.target = parent_obj
@classmethod
def lock_children_transform(cls, parent_element, lock_state=True):
for child_obj in cls.get_all_children_objects(parent_element):
for prop in ("lock_location", "lock_rotation", "lock_scale"):
attr = getattr(child_obj, prop)
for axis_idx in range(3):
attr[axis_idx] = lock_state
@classmethod
def get_all_objects(cls, parent_element):
parent_obj = tool.Ifc.get_object(parent_element)