mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 10:11:46 +00:00
Fix error trying to access unset ifc file
This commit is contained in:
@@ -43,8 +43,10 @@ def getIfcTypes(self, context):
|
|||||||
def getAvailableTypes(self, context):
|
def getAvailableTypes(self, context):
|
||||||
global available_types_enum
|
global available_types_enum
|
||||||
if len(available_types_enum) < 1:
|
if len(available_types_enum) < 1:
|
||||||
elements = IfcStore.get_file().by_type(self.ifc_class)
|
file = IfcStore.get_file()
|
||||||
available_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
|
if file:
|
||||||
|
elements = file.by_type(self.ifc_class)
|
||||||
|
available_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
|
||||||
return available_types_enum
|
return available_types_enum
|
||||||
|
|
||||||
|
|
||||||
@@ -58,17 +60,21 @@ def updateTypeInstanceIfcClass(self, context):
|
|||||||
def getApplicableTypes(self, context):
|
def getApplicableTypes(self, context):
|
||||||
global applicable_types_enum
|
global applicable_types_enum
|
||||||
if len(applicable_types_enum) < 1:
|
if len(applicable_types_enum) < 1:
|
||||||
element = IfcStore.get_file().by_id(context.active_object.BIMObjectProperties.ifc_definition_id)
|
file = IfcStore.get_file()
|
||||||
types = ifcopenshell.util.type.get_applicable_types(element.is_a(), schema=IfcStore.get_file().schema)
|
if file:
|
||||||
applicable_types_enum.extend((t, t, "") for t in types)
|
element = file.by_id(context.active_object.BIMObjectProperties.ifc_definition_id)
|
||||||
|
types = ifcopenshell.util.type.get_applicable_types(element.is_a(), schema=IfcStore.get_file().schema)
|
||||||
|
applicable_types_enum.extend((t, t, "") for t in types)
|
||||||
return applicable_types_enum
|
return applicable_types_enum
|
||||||
|
|
||||||
|
|
||||||
def getRelatingTypes(self, context):
|
def getRelatingTypes(self, context):
|
||||||
global relating_types_enum
|
global relating_types_enum
|
||||||
if len(relating_types_enum) < 1:
|
if len(relating_types_enum) < 1:
|
||||||
elements = IfcStore.get_file().by_type(context.active_object.BIMTypeProperties.relating_type_class)
|
file = IfcStore.get_file()
|
||||||
relating_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
|
if file:
|
||||||
|
elements = file.by_type(context.active_object.BIMTypeProperties.relating_type_class)
|
||||||
|
relating_types_enum.extend((str(e.id()), e.Name, "") for e in elements)
|
||||||
return relating_types_enum
|
return relating_types_enum
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user