From d3a5071d9d3fa9d6da63c8eea04de4db3b1aa6a6 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 12 Oct 2025 21:07:13 +1100 Subject: [PATCH] Fix #7211. Explain to user why they can't remove the last grid axis. --- src/bonsai/bonsai/bim/module/geometry/operator.py | 11 ++++++++++- src/bonsai/bonsai/tool/geometry.py | 3 --- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/geometry/operator.py b/src/bonsai/bonsai/bim/module/geometry/operator.py index 401428cddb..a5218b3dfa 100644 --- a/src/bonsai/bonsai/bim/module/geometry/operator.py +++ b/src/bonsai/bonsai/bim/module/geometry/operator.py @@ -882,7 +882,16 @@ class OverrideDelete(bpy.types.Operator): continue if ifcopenshell.util.element.get_pset(element, "BBIM_Array"): self.report({"INFO"}, "Elements that are part of an array cannot be deleted.") - return {"FINISHED"} + continue + if element.is_a("IfcGridAxis"): + # Deleting the last W axis is OK + if ((grid := element.PartOfU) and len(grid[0].UAxes) == 1) or ( + (grid := element.PartOfV) and len(grid[0].VAxes) == 1 + ): + self.report( + {"INFO"}, "The last grid axis of a grid cannot be deleted. Delete the grid instead." + ) + continue tool.Geometry.delete_ifc_object(obj) elif tool.Geometry.is_representation_item(obj): tool.Geometry.delete_ifc_item(obj) diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index a5625de761..c31d1e0fbb 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -243,13 +243,10 @@ class Geometry(bonsai.core.tool.Geometry): tool.Boundary.undecorate_boundary(obj) return bpy.data.objects.remove(obj) elif element.is_a("IfcGridAxis"): - is_last_axis = False # Deleting the last W axis is OK if ((grid := element.PartOfU) and len(grid[0].UAxes) == 1) or ( (grid := element.PartOfV) and len(grid[0].VAxes) == 1 ): - is_last_axis = True - if is_last_axis: return ifcopenshell.api.grid.remove_grid_axis(ifc_file, axis=element) return bpy.data.objects.remove(obj)