Remove constraints when object is unassigned from the aggregate.

This commit is contained in:
Bruno Perdigão
2024-11-15 10:53:31 -03:00
committed by Bruno Perdigão
parent 7f838f81b4
commit 0daf4c9324
2 changed files with 11 additions and 1 deletions
@@ -96,6 +96,8 @@ 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))
# Removes Pset related to Linked Aggregates
if not element.is_a("IfcElementAssembly"):
pset = ifcopenshell.util.element.get_pset(element, "BBIM_Linked_Aggregate")
+9 -1
View File
@@ -85,7 +85,7 @@ class Aggregate(bonsai.core.tool.Aggregate):
return parts
@classmethod
def constrain_parts_to_aggregate(cls, aggregate: ifcopenshell.entity_instance):
def constrain_parts_to_aggregate(cls, aggregate: bpy.types.Object):
agg_element = tool.Ifc.get_entity(aggregate)
parts = ifcopenshell.util.element.get_parts(agg_element)
parts_objs = [tool.Ifc.get_object(p) for p in parts]
@@ -95,3 +95,11 @@ class Aggregate(bonsai.core.tool.Aggregate):
obj.constraints.remove(constraint)
constraint = obj.constraints.new("CHILD_OF")
constraint.target = aggregate
@classmethod
def remove_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)