From 4d01dfe3790e0a4166d4283da1637de90e77c77b Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 29 May 2023 17:20:55 +1000 Subject: [PATCH] Fix #3138. Remove manual copy class and be more intelligent about what classe can be reassigned. --- src/blenderbim/blenderbim/bim/module/root/data.py | 11 +++++++++++ src/blenderbim/blenderbim/bim/module/root/ui.py | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/root/data.py b/src/blenderbim/blenderbim/bim/module/root/data.py index 123440327c..4d4d9c4a8e 100644 --- a/src/blenderbim/blenderbim/bim/module/root/data.py +++ b/src/blenderbim/blenderbim/bim/module/root/data.py @@ -44,6 +44,7 @@ class IfcClassData: cls.data["name"] = cls.name() cls.data["ifc_class"] = cls.ifc_class() cls.data["ifc_predefined_types"] = cls.ifc_predefined_types() + cls.data["can_reassign_class"] = cls.can_reassign_class() @classmethod def ifc_products(cls): @@ -172,3 +173,13 @@ class IfcClassData: element = tool.Ifc.get_entity(bpy.context.active_object) if element: return element.is_a() + + @classmethod + def can_reassign_class(cls): + element = tool.Ifc.get_entity(bpy.context.active_object) + if element: + if element.is_a("IfcOpeningElement") or element.is_a("IfcOpeningStandardCase"): + return False + for product in cls.ifc_products(): + if element.is_a(product[0]): + return True diff --git a/src/blenderbim/blenderbim/bim/module/root/ui.py b/src/blenderbim/blenderbim/bim/module/root/ui.py index df06f4bae0..2004f7ed08 100644 --- a/src/blenderbim/blenderbim/bim/module/root/ui.py +++ b/src/blenderbim/blenderbim/bim/module/root/ui.py @@ -62,9 +62,8 @@ class BIM_PT_class(Panel): row.label(text=IfcClassData.data["name"]) op = row.operator("bim.select_ifc_class", text="", icon="RESTRICT_SELECT_OFF") op.ifc_class = IfcClassData.data["ifc_class"] - row.operator("bim.copy_class", icon="DUPLICATE", text="") row.operator("bim.unlink_object", icon="UNLINKED", text="") - if IfcStore.get_file().by_id(props.ifc_definition_id).is_a("IfcRoot"): + if IfcClassData.data["can_reassign_class"]: row.operator("bim.enable_reassign_class", icon="GREASEPENCIL", text="") else: ifc_predefined_types = root_prop.get_ifc_predefined_types(context.scene.BIMRootProperties, context)