mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 10:34:31 +00:00
Remove constraints when object is unassigned from the aggregate.
This commit is contained in:
committed by
Bruno Perdigão
parent
7f838f81b4
commit
0daf4c9324
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user