From 1cf7f6590230b3700892f9e88ccf0a32ef2f6879 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 26 Sep 2024 18:23:19 +0500 Subject: [PATCH] Hide non-simple property types to avoid breaking UI #5496 Property types that are now skipped (at least in IFC4): >>>> ('list', 'integer') > binary >> ('array', 'float') >> ('list', 'integer') >>>> ('list', 'integer') >> ('set', 'entity') --- src/bonsai/bonsai/bim/module/pset/data.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/pset/data.py b/src/bonsai/bonsai/bim/module/pset/data.py index e9768ff0ab..4fe04538b7 100644 --- a/src/bonsai/bonsai/bim/module/pset/data.py +++ b/src/bonsai/bonsai/bim/module/pset/data.py @@ -18,6 +18,7 @@ import bpy import ifcopenshell +import ifcopenshell.util.attribute import ifcopenshell.util.doc import ifcopenshell.util.element import bonsai.tool as tool @@ -327,9 +328,15 @@ class AddEditCustomPropertiesData: @classmethod def primary_measure_type(cls): + SIMPLE_TYPES = {"string", "integer", "float", "boolean"} schema = tool.Ifc.schema() version = tool.Ifc.get_schema() - return [ - (t, t, ifcopenshell.util.doc.get_type_doc(version, t).get("description", "")) - for t in sorted([d.name() for d in schema.declarations() if hasattr(d, "declared_type")]) + # Skip non-simple types as they're currently not supported (e.g. IfcBinary and lists/arrays/sets of types). + declarations = [ + d.name() + for d in schema.declarations() + if hasattr(d, "declared_type") and ifcopenshell.util.attribute.get_primitive_type(d) in SIMPLE_TYPES + ] + return [ + (t, t, ifcopenshell.util.doc.get_type_doc(version, t).get("description", "")) for t in sorted(declarations) ]