diff --git a/src/bonsai/bonsai/bim/module/classification/ui.py b/src/bonsai/bonsai/bim/module/classification/ui.py index 7cbfb0ed93..344c247af2 100644 --- a/src/bonsai/bonsai/bim/module/classification/ui.py +++ b/src/bonsai/bonsai/bim/module/classification/ui.py @@ -282,7 +282,11 @@ class BIM_PT_classification_references(Panel, ReferenceUI): @classmethod def poll(cls, context): - return bool((obj := context.active_object) and tool.Ifc.get_entity(obj)) + return ( + (obj := tool.Blender.get_active_object()) + and (element := tool.Ifc.get_entity(obj)) + and element.is_a("IfcObjectDefinition") + ) def get_object_name(self, context: bpy.types.Context) -> str: assert (obj := context.active_object) diff --git a/src/bonsai/bonsai/bim/module/pset/ui.py b/src/bonsai/bonsai/bim/module/pset/ui.py index ab11c5f1ce..abd3a8b90f 100644 --- a/src/bonsai/bonsai/bim/module/pset/ui.py +++ b/src/bonsai/bonsai/bim/module/pset/ui.py @@ -242,14 +242,11 @@ class BIM_PT_object_psets(Panel): @classmethod def poll(cls, context): - if not (obj := context.active_object): - return False - ifc_id = tool.Blender.get_ifc_definition_id(obj) - if not ifc_id: - return False - if not tool.Ifc.get_object_by_identifier(ifc_id): - return False - return True + return ( + (obj := tool.Blender.get_active_object()) + and (element := tool.Ifc.get_entity(obj)) + and element.is_a("IfcObjectDefinition") + ) def draw(self, context): if not ObjectPsetsData.is_loaded: @@ -388,14 +385,11 @@ class BIM_PT_object_qtos(Panel): @classmethod def poll(cls, context): - if not (obj := context.active_object): - return False - ifc_id = tool.Blender.get_ifc_definition_id(obj) - if not ifc_id: - return False - if not tool.Ifc.get_object_by_identifier(ifc_id): - return False - return True + return ( + (obj := tool.Blender.get_active_object()) + and (element := tool.Ifc.get_entity(obj)) + and element.is_a("IfcObjectDefinition") + ) def draw(self, context): if not ObjectQtosData.is_loaded: diff --git a/src/bonsai/bonsai/bim/module/type/ui.py b/src/bonsai/bonsai/bim/module/type/ui.py index dd08278bc9..f749ceb07e 100644 --- a/src/bonsai/bonsai/bim/module/type/ui.py +++ b/src/bonsai/bonsai/bim/module/type/ui.py @@ -34,14 +34,11 @@ class BIM_PT_type(Panel): @classmethod def poll(cls, context): - if not context.active_object: - return False - element = tool.Ifc.get_entity(context.active_object) - if not element: - return False - if not element.is_a("IfcProduct") and not element.is_a("IfcTypeProduct"): - return True - return True + return ( + (obj := tool.Blender.get_active_object()) + and (element := tool.Ifc.get_entity(obj)) + and (element.is_a("IfcObject") or element.is_a("IfcTypeObject")) + ) def draw(self, context): if not TypeData.is_loaded: