mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Add description for pset enum properties too
Example - https://files.catbox.moe/ysmw6v.png
This commit is contained in:
@@ -37,6 +37,7 @@ import bonsai.tool as tool
|
||||
from ifcopenshell.util.file import IfcHeaderExtractor
|
||||
from bonsai.bim.prop import Attribute
|
||||
from bonsai.bim.module.bsdd.prop import BIMBSDDProperties
|
||||
from bonsai.bim.module.pset.prop import IfcProperty
|
||||
from typing import Optional, TYPE_CHECKING, Literal
|
||||
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):
|
||||
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
|
||||
ifc_class = attr.ifc_class
|
||||
if ifc_class:
|
||||
|
||||
@@ -210,6 +210,7 @@ class Pset(bonsai.core.tool.Pset):
|
||||
metadata.name = prop.Name
|
||||
metadata.is_null = len(simple_prop.enumerated_value.enumerated_values) == 0
|
||||
metadata.is_optional = True
|
||||
process_prop_description(metadata)
|
||||
enum_reference = prop.EnumerationReference
|
||||
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_optional = True
|
||||
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
|
||||
metadata.set_value(enum_items[0])
|
||||
|
||||
Reference in New Issue
Block a user