From a67a6034a50534f0b5bcabbc875178feae9cb7f7 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 5 May 2025 17:40:38 +0500 Subject: [PATCH] Use mesh.separate for vanilla Blender objects #6658 (0b22333) mesh.separate works completely different in EDIT mode, previously we only supported it from object mode --- src/bonsai/bonsai/bim/module/geometry/operator.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/geometry/operator.py b/src/bonsai/bonsai/bim/module/geometry/operator.py index 4a3be7c9b2..879f263f8c 100644 --- a/src/bonsai/bonsai/bim/module/geometry/operator.py +++ b/src/bonsai/bonsai/bim/module/geometry/operator.py @@ -99,8 +99,18 @@ class OverrideMeshSeparate(bpy.types.Operator, tool.Ifc.Operator): return self.execute(context) def _execute(self, context): - if self.type == "SELECTED" and context.mode != "EDIT": - self.report({"ERROR"}, "Separate by selection requires EDIT mode.") + if not tool.Ifc.get(): + return bpy.ops.mesh.separate(type=self.type) + elif context.mode == "EDIT_MESH": + if any( + tool.Ifc.get_entity(obj) or tool.Geometry.is_representation_item(obj) for obj in context.objects_in_mode + ): + self.report({"WARNING"}, "IFC Separate is not yet supported for EDIT mode with IFC elements.") + return {"CANCELLED"} + return bpy.ops.mesh.separate(type=self.type) + + if self.type == "SELECTED": + self.report({"ERROR"}, "Separate by selection requires 'EDIT_MESH' mode.") return {"CANCELLED"} non_ifc_objects: list[bpy.types.Object] = []