Add description for pset enum properties too

Example - https://files.catbox.moe/ysmw6v.png
This commit is contained in:
Andrej730
2025-09-02 17:03:51 +05:00
parent df4f565176
commit 99ca1c7eb4
2 changed files with 14 additions and 0 deletions
+12
View File
@@ -37,6 +37,7 @@ import bonsai.tool as tool
from ifcopenshell.util.file import IfcHeaderExtractor from ifcopenshell.util.file import IfcHeaderExtractor
from bonsai.bim.prop import Attribute from bonsai.bim.prop import Attribute
from bonsai.bim.module.bsdd.prop import BIMBSDDProperties from bonsai.bim.module.bsdd.prop import BIMBSDDProperties
from bonsai.bim.module.pset.prop import IfcProperty
from typing import Optional, TYPE_CHECKING, Literal from typing import Optional, TYPE_CHECKING, Literal
from natsort import natsorted from natsort import natsorted
@@ -1424,6 +1425,17 @@ def draw_custom_context_menu(self: bpy.types.Menu, context: bpy.types.Context) -
if isinstance(prop_struct, Attribute): if isinstance(prop_struct, Attribute):
attr = prop_struct attr = prop_struct
# Hacky way to get Attribute containing description for enumerated values.
pset_enum_identifier = ".enumerated_value.enumerated_values["
attr_path = prop_struct.path_from_id()
if pset_enum_identifier in attr_path:
attr_path = attr_path.partition(pset_enum_identifier)[0]
assert (data_block := prop_struct.id_data)
attr = data_block.path_resolve(attr_path)
assert isinstance(attr, IfcProperty)
attr = attr.metadata
description = attr.description description = attr.description
ifc_class = attr.ifc_class ifc_class = attr.ifc_class
if ifc_class: if ifc_class:
+2
View File
@@ -210,6 +210,7 @@ class Pset(bonsai.core.tool.Pset):
metadata.name = prop.Name metadata.name = prop.Name
metadata.is_null = len(simple_prop.enumerated_value.enumerated_values) == 0 metadata.is_null = len(simple_prop.enumerated_value.enumerated_values) == 0
metadata.is_optional = True metadata.is_optional = True
process_prop_description(metadata)
enum_reference = prop.EnumerationReference enum_reference = prop.EnumerationReference
selected_enum_items = [v.wrappedValue for v in (prop.EnumerationValues or ())] selected_enum_items = [v.wrappedValue for v in (prop.EnumerationValues or ())]
@@ -297,6 +298,7 @@ class Pset(bonsai.core.tool.Pset):
metadata.is_null = data.get(prop_template.Name, None) is None metadata.is_null = data.get(prop_template.Name, None) is None
metadata.is_optional = True metadata.is_optional = True
metadata.special_type = "URI" if prop_template.PrimaryMeasureType == "IfcURIReference" else "" metadata.special_type = "URI" if prop_template.PrimaryMeasureType == "IfcURIReference" else ""
bonsai.bim.helper.add_attribute_description(metadata, prop_template)
# Cute hack to abuse the metadata to find the Blender data_type # Cute hack to abuse the metadata to find the Blender data_type
metadata.set_value(enum_items[0]) metadata.set_value(enum_items[0])