Fix errors if no ifc file

This commit is contained in:
Gorgious
2021-08-19 22:46:01 +02:00
parent b5ff3cd818
commit 1c9cd058c8
3 changed files with 6 additions and 1 deletions
@@ -110,6 +110,8 @@ class BIM_PT_material_attributes(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_file():
return False
try:
return bool(context.active_object.active_material.BIMObjectProperties.ifc_definition_id)
except:
@@ -207,7 +207,8 @@ class BIM_PT_material_psets(Panel):
props = context.active_object.active_material.BIMObjectProperties
if not props.ifc_definition_id:
return False
if IfcStore.get_file().schema == "IFC2X3":
file = IfcStore.get_file()
if not file or file.schema == "IFC2X3":
return False # We don't support material psets in IFC2X3 because they suck
if props.ifc_definition_id not in Data.products:
Data.load(IfcStore.get_file(), props.ifc_definition_id)
@@ -59,6 +59,8 @@ class BIM_PT_style_attributes(Panel):
@classmethod
def poll(cls, context):
if not IfcStore.get_file():
return False
try:
return bool(context.active_object.active_material.BIMMaterialProperties.ifc_style_id)
except: