Apply aggregate constraints instead of removing.

This commit is contained in:
Bruno Perdigão
2024-11-16 12:59:40 -03:00
committed by Bruno Perdigão
parent 0daf4c9324
commit 6f11f74aac
2 changed files with 7 additions and 5 deletions
@@ -96,7 +96,7 @@ class BIM_OT_aggregate_unassign_object(bpy.types.Operator, tool.Ifc.Operator):
related_obj=tool.Ifc.get_object(element),
)
tool.Aggregate.remove_constraints(tool.Ifc.get_object(element))
tool.Aggregate.apply_constraints(tool.Ifc.get_object(element))
# Removes Pset related to Linked Aggregates
if not element.is_a("IfcElementAssembly"):
+6 -4
View File
@@ -90,6 +90,9 @@ class Aggregate(bonsai.core.tool.Aggregate):
parts = ifcopenshell.util.element.get_parts(agg_element)
parts_objs = [tool.Ifc.get_object(p) for p in parts]
for obj in parts_objs:
if not obj.data:
continue
tool.Geometry.lock_object(obj)
constraint = next((c for c in obj.constraints if c.type == "CHILD_OF"), None)
if constraint:
obj.constraints.remove(constraint)
@@ -97,9 +100,8 @@ class Aggregate(bonsai.core.tool.Aggregate):
constraint.target = aggregate
@classmethod
def remove_constraints(cls, part: bpy.types.Object):
def apply_constraints(cls, part: bpy.types.Object):
constraint = next((c for c in part.constraints if c.type == "CHILD_OF"), None)
if constraint:
part.constraints.remove(constraint)
bpy.ops.constraint.apply(constraint=constraint.name)
tool.Geometry.unlock_object(part)