From c535dcd2061b3a3706cfb6c9aee7b9ef99e37010 Mon Sep 17 00:00:00 2001 From: CyrilWaechter Date: Sun, 2 Aug 2026 06:48:25 +0200 Subject: [PATCH] Bonsai: commit moved bounding objects before IFC-based space generation The auto-generate-ifc-based-space-boundaries path builds a geometry cache from the IFC file. If a user (or a BDD helper) only moves the Blender object matrix, the cache still sees the old IFC placement and the space footprint is open. Commit any moved visible bounding objects and clear the cache before generating the space. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/tool/spatial.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bonsai/bonsai/tool/spatial.py b/src/bonsai/bonsai/tool/spatial.py index 37e0302f8f..16baba257d 100644 --- a/src/bonsai/bonsai/tool/spatial.py +++ b/src/bonsai/bonsai/tool/spatial.py @@ -885,6 +885,15 @@ class Spatial(bonsai.core.tool.Spatial): container_obj = tool.Ifc.get_object(container) cut_z = container_obj.matrix_world.translation.z + calculation_rl + # Commit any moved visible bounding objects before reading IFC geometry, + # so the IFC-based cache uses the current Blender positions. + for obj in bpy.context.visible_objects: + element = tool.Ifc.get_entity(obj) + if element is None or not any(element.is_a(c) for c in ifcopenshell.util.space.BOUNDING_CLASSES): + continue + tool.Geometry.commit_placement_if_moved(obj) + cls._geom_cache.clear() + boundary_lines, bounding_elements = cls.get_boundary_lines_from_ifc_elements(cut_z) polygon, _ = ifcopenshell.util.space.get_space_polygon(boundary_lines, x, y) if isinstance(polygon, str):