From 4d92a64206938405dca4867a3ba6051a4b0fc27f Mon Sep 17 00:00:00 2001 From: Gorgious56 Date: Thu, 2 Jul 2026 09:18:13 +0200 Subject: [PATCH] Bonsai: skip sibling refresh on show/hide toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EditOpenings.edit_openings unconditionally walked sibling wall sets twice on every processed opening — once by mapped source id via get_similar_openings_building_objs, once by filling type via get_all_building_objects_of_similar_openings — and unioned both into the building_objs recut set. reload_body_representation then hit every one of those walls with a switch_representation call, even for the show/hide toggle path where nothing about the opening changed. Move both sibling-wall unions inside the is_edited / is_moved branch. Pure show/hide (no shape edit, no move) now touches only the wall(s) directly hosting the toggled openings. The edit and move paths still refresh siblings the same as before, since a mapped-source rewrite propagates the new shape to every sharing wall and each one needs a recut. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/bim/module/model/opening.py | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/opening.py b/src/bonsai/bonsai/bim/module/model/opening.py index d144bacf69..fffa84c7c7 100644 --- a/src/bonsai/bonsai/bim/module/model/opening.py +++ b/src/bonsai/bonsai/bim/module/model/opening.py @@ -977,27 +977,29 @@ class EditOpenings(Operator, tool.Ifc.Operator): for opening_element in opening_elements: opening_obj = tool.Ifc.get_object(opening_element) - similar_openings = bonsai.core.geometry.get_similar_openings(tool.Ifc, opening_element) - similar_openings_building_objs = bonsai.core.geometry.get_similar_openings_building_objs( - tool.Ifc, similar_openings - ) - building_objs.update(similar_openings_building_objs) - if opening_obj: - if tool.Ifc.is_edited(opening_obj): - tool.Geometry.run_geometry_update_representation(obj=opening_obj) - bonsai.core.geometry.edit_similar_opening_placement( - tool.Geometry, opening_element, similar_openings - ) - elif tool.Ifc.is_moved(opening_obj): - bonsai.core.geometry.edit_object_placement(tool.Ifc, tool.Geometry, tool.Surveyor, obj=opening_obj) + opening_edited = tool.Ifc.is_edited(opening_obj) + opening_moved = tool.Ifc.is_moved(opening_obj) + # Sibling walls only need a viewport-level refresh when the + # opening's shape or placement actually changed — a pure + # show/hide toggle leaves them in their existing state. + if opening_edited or opening_moved: + similar_openings = bonsai.core.geometry.get_similar_openings(tool.Ifc, opening_element) + similar_openings_building_objs = bonsai.core.geometry.get_similar_openings_building_objs( + tool.Ifc, similar_openings + ) + building_objs.update(similar_openings_building_objs) + if opening_edited: + tool.Geometry.run_geometry_update_representation(obj=opening_obj) + else: + bonsai.core.geometry.edit_object_placement( + tool.Ifc, tool.Geometry, tool.Surveyor, obj=opening_obj + ) bonsai.core.geometry.edit_similar_opening_placement( tool.Geometry, opening_element, similar_openings ) + building_objs.update(self.get_all_building_objects_of_similar_openings(opening_element)) - building_objs.update( - self.get_all_building_objects_of_similar_openings(opening_element) - ) # NB this has nothing to do with clone similar_opening tool.Ifc.unlink(element=opening_element) if props.representation_obj == opening_obj: props.representation_obj = None