From 7ec1bc5272576b7047c918b995c3e9d6fb1fbe73 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 4 Feb 2025 12:23:29 +0500 Subject: [PATCH] Fix error toggling boundary decorations after one was removed #6088 --- src/bonsai/bonsai/bim/module/boundary/prop.py | 2 +- src/bonsai/bonsai/tool/boundary.py | 5 +++++ src/bonsai/bonsai/tool/geometry.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/module/boundary/prop.py b/src/bonsai/bonsai/bim/module/boundary/prop.py index cb0067b892..dc76de0e00 100644 --- a/src/bonsai/bonsai/bim/module/boundary/prop.py +++ b/src/bonsai/bonsai/bim/module/boundary/prop.py @@ -70,7 +70,7 @@ class BIMObjectBoundaryProperties(PropertyGroup): class BIMBoundaryProperties(PropertyGroup): - boundaries: bpy.props.CollectionProperty(type=ObjProperty) + boundaries: bpy.props.CollectionProperty(type=ObjProperty, description="Decorated boundaries") if TYPE_CHECKING: boundaries: bpy.types.bpy_prop_collection_idprop[ObjProperty] diff --git a/src/bonsai/bonsai/tool/boundary.py b/src/bonsai/bonsai/tool/boundary.py index dfa8962fff..1d13151473 100644 --- a/src/bonsai/bonsai/tool/boundary.py +++ b/src/bonsai/bonsai/tool/boundary.py @@ -96,3 +96,8 @@ class Boundary(bonsai.core.tool.Boundary): @classmethod def undecorate_boundary(cls, obj: bpy.types.Object) -> None: obj.show_in_front = False + props = cls.get_boundary_props() + for i in reversed(range(len(props.boundaries))): + if props.boundaries[i].obj == obj: + props.boundaries.remove(i) + break diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index cc951596e3..8499638841 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -195,6 +195,7 @@ class Geometry(bonsai.core.tool.Geometry): return bonsai.core.drawing.remove_drawing(tool.Ifc, tool.Drawing, drawing=element) elif element.is_a("IfcRelSpaceBoundary"): ifcopenshell.api.run("boundary.remove_boundary", tool.Ifc.get(), boundary=element) + tool.Boundary.undecorate_boundary(obj) return bpy.data.objects.remove(obj) elif element.is_a("IfcGridAxis"): is_last_axis = False