Fix bug where panels for psets/qtos/classifications/types were showing up on irrelevant objects (e.g. grid axes)

This commit is contained in:
Dion Moult
2025-10-23 08:59:15 +11:00
parent 5b5dcb3c6d
commit d1453e1139
3 changed files with 20 additions and 25 deletions
@@ -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)
+10 -16
View File
@@ -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:
+5 -8
View File
@@ -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: