fix umlauts not showing up correctly in dynamic enums #1941 (#1945)

* first attempt

* adopted new solution for umlauts in enums

* fix typo
This commit is contained in:
Vukas Pajic
2022-01-04 03:09:47 +01:00
committed by GitHub
parent e384dbd548
commit 2c0df1d4f5
+29 -4
View File
@@ -24,6 +24,7 @@ import ifcopenshell
import ifcopenshell.util.pset import ifcopenshell.util.pset
import blenderbim.bim.handler import blenderbim.bim.handler
from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ifc import IfcStore
from collections import defaultdict
from bpy.types import PropertyGroup from bpy.types import PropertyGroup
from bpy.props import ( from bpy.props import (
PointerProperty, PointerProperty,
@@ -191,12 +192,36 @@ def update_is_visible(self, context):
pass 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 # 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): if isinstance(data, dict):
return [(str(k), v, "") for k, v in data.items()] for k, v in data.items():
return [(e, e, "") 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): def update_schema_dir(self, context):