Array children are now transform-unlocked & unconstrained when the array is applied

This commit is contained in:
Gorgious
2023-07-23 14:01:17 +02:00
parent a2042fc7f0
commit ea1e7c567f
2 changed files with 12 additions and 0 deletions
@@ -171,6 +171,10 @@ class RemoveArray(bpy.types.Operator, tool.Ifc.Operator):
tool.Model.regenerate_array(parent, data, self.keep_objs)
if self.keep_objs:
tool.Blender.Modifier.Array.unconstrain_children_from_parent(element)
tool.Blender.Modifier.Array.lock_children_transform(element, False)
pset = tool.Ifc.get().by_id(pset["id"])
if len(data) == 1:
ifcopenshell.api.run("pset.remove_pset", tool.Ifc.get(), pset=pset)
@@ -532,6 +532,14 @@ class Blender:
) or child.constraints.new("CHILD_OF")
constraint.target = parent_obj
@classmethod
def unconstrain_children_from_parent(cls, parent_element):
children = cls.get_all_children_objects(parent_element)
for child in children:
constraint = next((c for c in child.constraints if c.type == "CHILD_OF"), None)
if constraint:
child.constraints.remove(constraint)
@classmethod
def lock_children_transform(cls, parent_element, lock_state=True):
for child_obj in cls.get_all_children_objects(parent_element):