From 3d4321f713389a9ef1f0fb070a31d5956d76812b Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 13 May 2025 11:44:12 +0500 Subject: [PATCH] Prevent class assignment in non-object mode #6697 Example - https://i.imgur.com/KQYQLQZ.png --- src/bonsai/bonsai/bim/module/root/operator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bonsai/bonsai/bim/module/root/operator.py b/src/bonsai/bonsai/bim/module/root/operator.py index 0a560b7cd1..66520df2fc 100644 --- a/src/bonsai/bonsai/bim/module/root/operator.py +++ b/src/bonsai/bonsai/bim/module/root/operator.py @@ -195,6 +195,17 @@ class AssignClass(bpy.types.Operator, tool.Ifc.Operator): should_add_representation: bool ifc_representation_class: str + @classmethod + def poll(cls, context): + if not tool.Ifc.get(): + cls.poll_message_set("No IFC project loaded.") + return False + # object.select_all operator's requirement and it's generally more safe. + elif context.mode != "OBJECT": + cls.poll_message_set(f"Can only assign class in OBJECT mode, not in {context.mode} mode.") + return False + return True + def _execute(self, context): ifc_file = tool.Ifc.get() props = tool.Root.get_root_props()