bim.clone_opening - update affected representations

This commit is contained in:
Andrej730
2025-01-16 17:14:03 +05:00
parent eef04fb91c
commit 50b39fdd10
2 changed files with 20 additions and 1 deletions
@@ -1129,6 +1129,25 @@ class CloneOpening(Operator, tool.Ifc.Operator):
ifcopenshell.api.void.add_opening(ifc_file, opening=new_opening, element=voided_element)
new_opening.ObjectPlacement = opening_placement
# Update affected representations.
elements_to_update = tool.Aggregate.get_parts_recursively(voided_element)
for element in elements_to_update:
obj = tool.Ifc.get_object(element)
if not isinstance(obj, bpy.types.Object) or not isinstance(obj.data, bpy.types.Mesh):
continue
representation = tool.Geometry.get_active_representation(obj)
assert representation
bonsai.core.geometry.switch_representation(
tool.Ifc,
tool.Geometry,
obj=obj,
representation=representation,
should_reload=True,
is_global=True,
should_sync_changes_first=False,
)
return {"FINISHED"}
+1 -1
View File
@@ -76,6 +76,7 @@ class Aggregate(bonsai.core.tool.Aggregate):
@classmethod
def get_parts_recursively(cls, element: ifcopenshell.entity_instance) -> set[ifcopenshell.entity_instance]:
"""Get elements parts recursively, resulting set includes `element`."""
parts = set()
queue = {element}
while queue:
@@ -122,7 +123,6 @@ class Aggregate(bonsai.core.tool.Aggregate):
editing_obj = props.editing_objects.add()
editing_obj.obj = obj.original
props.in_aggregate_mode = True
return {"FINISHED"}