mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
adopt new solution for enumerations and umlauts
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user