From ca3b4d17ba93dda697e2e3ff2c277af2806085b7 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 16 Mar 2022 09:37:20 +1100 Subject: [PATCH] Fix #2055. Disable IfcContext in IFC2X3 because it didn't exist. --- .../blenderbim/bim/module/root/data.py | 26 ++++++++++++++++ .../blenderbim/bim/module/root/prop.py | 31 +++---------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/root/data.py b/src/blenderbim/blenderbim/bim/module/root/data.py index 365bd4ac54..a6d3270e33 100644 --- a/src/blenderbim/blenderbim/bim/module/root/data.py +++ b/src/blenderbim/blenderbim/bim/module/root/data.py @@ -33,12 +33,38 @@ class IfcClassData: def load(cls): cls.is_loaded = True cls.data = { + "ifc_products": cls.ifc_products(), "contexts": cls.contexts(), "has_entity": cls.has_entity(), "name": cls.name(), "ifc_class": cls.ifc_class(), } + @classmethod + def ifc_products(cls): + products = [ + "IfcElement", + "IfcElementType", + "IfcSpatialElement", + "IfcGroup", + "IfcStructuralItem", + "IfcContext", + "IfcAnnotation", + "IfcRelSpaceBoundary", + ] + if tool.Ifc.get_schema() == "IFC2X3": + products = [ + "IfcElement", + "IfcElementType", + "IfcSpatialStructureElement", + "IfcGroup", + "IfcStructuralItem", + "IfcAnnotation", + "IfcRelSpaceBoundary", + ] + return [(e, e, "") for e in products] + + @classmethod def contexts(cls): results = [] diff --git a/src/blenderbim/blenderbim/bim/module/root/prop.py b/src/blenderbim/blenderbim/bim/module/root/prop.py index fd96b0c7cc..74bdc4679a 100644 --- a/src/blenderbim/blenderbim/bim/module/root/prop.py +++ b/src/blenderbim/blenderbim/bim/module/root/prop.py @@ -33,16 +33,13 @@ from bpy.props import ( CollectionProperty, ) -products_enum = [] classes_enum = [] types_enum = [] def purge(): - global products_enum global classes_enum global types_enum - products_enum = [] classes_enum = [] types_enum = [] @@ -76,28 +73,10 @@ def refreshPredefinedTypes(self, context): context.scene.BIMRootProperties.ifc_predefined_type = enum[0][0] -def getIfcProducts(self, context): - global products_enum - file = IfcStore.get_file() - if len(products_enum) < 1: - products_enum.extend( - [ - (e, e, "") - for e in [ - "IfcElement", - "IfcElementType", - "IfcSpatialElement", - "IfcGroup", - "IfcStructuralItem", - "IfcContext", - "IfcAnnotation", - "IfcRelSpaceBoundary", - ] - ] - ) - if file.schema == "IFC2X3": - products_enum[2] = ("IfcSpatialStructureElement", "IfcSpatialStructureElement", "") - return products_enum +def get_ifc_products(self, context): + if not IfcClassData.is_loaded: + IfcClassData.load() + return IfcClassData.data["ifc_products"] def getIfcClasses(self, context): @@ -118,7 +97,7 @@ def get_contexts(self, context): class BIMRootProperties(PropertyGroup): contexts: EnumProperty(items=get_contexts, name="Contexts") - ifc_product: EnumProperty(items=getIfcProducts, name="Products", update=refreshClasses) + ifc_product: EnumProperty(items=get_ifc_products, name="Products", update=refreshClasses) ifc_class: EnumProperty(items=getIfcClasses, name="Class", update=refreshPredefinedTypes) ifc_predefined_type: EnumProperty(items=getIfcPredefinedTypes, name="Predefined Type", default=None) ifc_userdefined_type: StringProperty(name="Userdefined Type")