diff --git a/src/blenderbim/blenderbim/bim/prop.py b/src/blenderbim/blenderbim/bim/prop.py index 0cf62385f3..f1d5673d65 100644 --- a/src/blenderbim/blenderbim/bim/prop.py +++ b/src/blenderbim/blenderbim/bim/prop.py @@ -24,6 +24,7 @@ import ifcopenshell import ifcopenshell.util.pset import blenderbim.bim.handler from blenderbim.bim.ifc import IfcStore +from collections import defaultdict from bpy.types import PropertyGroup from bpy.props import ( PointerProperty, @@ -191,12 +192,36 @@ def update_is_visible(self, context): pass -def getAttributeEnumValues(self, context): +def InternStr(s): + if not hasattr(InternStr, "StringCache"): # Another way to define a function attribute + InternStr.StringCache = defaultdict(str) + InternStr.StringCache[s] = s + return InternStr.StringCache[s] + +InternStr.StringCache = {} + +def getAttributeEnumValues(prop, context): # Support weird buildingSMART dictionary mappings which behave like enums - data = json.loads(self.enum_items) + items = [] + + data = json.loads(prop.enum_items) if isinstance(data, dict): - return [(str(k), v, "") for k, v in data.items()] - return [(e, e, "") for e in data] + for k, v in data.items(): + for e in data: + items.append(( + InternStr(k), + InternStr(v), + "", + )) + else: + for e in data: + items.append(( + InternStr(e), + InternStr(e), + "", + )) + + return items def update_schema_dir(self, context):