mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 15:08:51 +00:00
Apply aggregate constraints instead of removing.
This commit is contained in:
committed by
Bruno Perdigão
parent
0daf4c9324
commit
6f11f74aac
@@ -96,7 +96,7 @@ class BIM_OT_aggregate_unassign_object(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
related_obj=tool.Ifc.get_object(element),
|
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
|
# Removes Pset related to Linked Aggregates
|
||||||
if not element.is_a("IfcElementAssembly"):
|
if not element.is_a("IfcElementAssembly"):
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ class Aggregate(bonsai.core.tool.Aggregate):
|
|||||||
parts = ifcopenshell.util.element.get_parts(agg_element)
|
parts = ifcopenshell.util.element.get_parts(agg_element)
|
||||||
parts_objs = [tool.Ifc.get_object(p) for p in parts]
|
parts_objs = [tool.Ifc.get_object(p) for p in parts]
|
||||||
for obj in parts_objs:
|
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)
|
constraint = next((c for c in obj.constraints if c.type == "CHILD_OF"), None)
|
||||||
if constraint:
|
if constraint:
|
||||||
obj.constraints.remove(constraint)
|
obj.constraints.remove(constraint)
|
||||||
@@ -97,9 +100,8 @@ class Aggregate(bonsai.core.tool.Aggregate):
|
|||||||
constraint.target = aggregate
|
constraint.target = aggregate
|
||||||
|
|
||||||
@classmethod
|
@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)
|
constraint = next((c for c in part.constraints if c.type == "CHILD_OF"), None)
|
||||||
if constraint:
|
if constraint:
|
||||||
part.constraints.remove(constraint)
|
bpy.ops.constraint.apply(constraint=constraint.name)
|
||||||
|
tool.Geometry.unlock_object(part)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user