@@ -84,7 +84,13 @@ def cache_string(s: Any) -> str:
8484cache_string .data : dict [str , str ] = {}
8585
8686
87- def get_attribute_enum_values (prop : "Attribute" , context : bpy .types .Context ) -> list [tuple [str , str , str ]]:
87+ def get_attribute_enum_values (prop : "Attribute" , context : bpy .types .Context ) -> tool .Blender .BLENDER_ENUM_ITEMS :
88+ if "EnumData" not in globals () or TYPE_CHECKING :
89+ from bonsai .bim .ui import EnumData
90+
91+ if dynamic_identifier := prop .enum_items_dynamic :
92+ return EnumData .get_data (dynamic_identifier )
93+
8894 # Support weird buildingSMART dictionary mappings which behave like enums
8995 items : list [tuple [str , str , str ]] = []
9096 data = json .loads (prop .enum_items )
@@ -314,6 +320,11 @@ class Attribute(PropertyGroup):
314320 name = "Value" , description = tooltip , get = get_length_value , set = set_length_value , unit = "LENGTH"
315321 )
316322 enum_items : StringProperty (name = "Value" )
323+ """Json serialized mapping of enum items:
324+ Typically a dictionary of string identifiers to item names.
325+ """
326+ enum_items_dynamic : StringProperty ()
327+ """Dynamic enum items identifier."""
317328 enum_descriptions : CollectionProperty (type = StrProperty )
318329 enum_value : EnumProperty (items = get_attribute_enum_values , name = "Value" , update = update_attribute_value )
319330 filepath_value : PointerProperty (type = MultipleFileSelect )
@@ -343,6 +354,7 @@ class Attribute(PropertyGroup):
343354 float_value : float
344355 length_value : float
345356 enum_items : str
357+ enum_items_dynamic : str
346358 enum_descriptions : bpy .types .bpy_prop_collection_idprop [StrProperty ]
347359 enum_value : str
348360 filepath_value : MultipleFileSelect
@@ -365,7 +377,11 @@ def get_value(self) -> Union[str, float, int, bool, None]:
365377 return self .string_value .replace ("\\ n" , "\n " )
366378 if self .data_type == "file" :
367379 return [f .name for f in self .filepath_value .file_list ]
368- value = getattr (self , str (self .get_value_name ()), None )
380+ value_name = self .get_value_name ()
381+ if value_name == "enum_value" :
382+ value = tool .Blender .get_enum_safe (self , "enum_value" )
383+ else :
384+ value = getattr (self , value_name , None )
369385 if self .special_type == "LOGICAL" and value != "UNKNOWN" :
370386 # IfcOpenShell expects bool if IfcLogical is True/False.
371387 value = value == "TRUE"
0 commit comments