From 6782c47d86e472ce86bdf8374b89399725b757da Mon Sep 17 00:00:00 2001 From: Gorgious Date: Fri, 30 Jul 2021 08:45:17 +0200 Subject: [PATCH] Fix error trying to access unset ifc file --- .../blenderbim/bim/module/type/prop.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/type/prop.py b/src/blenderbim/blenderbim/bim/module/type/prop.py index fc7b6acab0..b0c34f0ce7 100644 --- a/src/blenderbim/blenderbim/bim/module/type/prop.py +++ b/src/blenderbim/blenderbim/bim/module/type/prop.py @@ -43,8 +43,10 @@ def getIfcTypes(self, context): def getAvailableTypes(self, context): global available_types_enum if len(available_types_enum) < 1: - elements = IfcStore.get_file().by_type(self.ifc_class) - available_types_enum.extend((str(e.id()), e.Name, "") for e in elements) + file = IfcStore.get_file() + 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 @@ -58,17 +60,21 @@ def updateTypeInstanceIfcClass(self, context): def getApplicableTypes(self, context): global applicable_types_enum if len(applicable_types_enum) < 1: - element = IfcStore.get_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) + file = IfcStore.get_file() + if file: + 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 def getRelatingTypes(self, context): global relating_types_enum if len(relating_types_enum) < 1: - elements = IfcStore.get_file().by_type(context.active_object.BIMTypeProperties.relating_type_class) - relating_types_enum.extend((str(e.id()), e.Name, "") for e in elements) + file = IfcStore.get_file() + 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