From a3efa7e9ee6391946bfae8931e8fbadf0fd22092 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 10 Apr 2026 19:10:15 +0500 Subject: [PATCH] util.element - fix IfcComplexProperty KeyError when verbose=True (#7921) Introduced by me in b77df1892 --- .../ifcopenshell/util/element.py | 2 +- .../test/util/test_element.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index 1c52ebc49d..8a8a817336 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -469,7 +469,7 @@ def get_properties( del data["HasProperties"] results[prop_name] = data if verbose: - results[prop_name] = {"id": data["id"], "class": data["class"], "value": results[prop_name]} + results[prop_name] = {"id": data["id"], "class": data["type"], "value": results[prop_name]} return results diff --git a/src/ifcopenshell-python/test/util/test_element.py b/src/ifcopenshell-python/test/util/test_element.py index 5eb6034402..ffd5789f01 100644 --- a/src/ifcopenshell-python/test/util/test_element.py +++ b/src/ifcopenshell-python/test/util/test_element.py @@ -307,6 +307,35 @@ class TestGetPropertiesIFC4(test.bootstrap.IFC4): } } + def test_getting_complex_properties_verbose(self): + element = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall") + pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="pset") + complex_property = self.file.create_entity("IfcComplexProperty", Name="prop", UsageName="usage_name") + ifcopenshell.api.pset.edit_pset(self.file, pset=complex_property, properties={"a": "b"}) + pset.HasProperties = [complex_property] + properties = subject.get_properties(pset.HasProperties, verbose=True) + prop_value = properties["prop"]["value"] + nested_prop = prop_value["properties"]["a"] + assert properties == { + "prop": { + "id": complex_property.id(), + "class": "IfcComplexProperty", + "value": { + "UsageName": "usage_name", + "id": complex_property.id(), + "type": "IfcComplexProperty", + "properties": { + "a": { + "id": nested_prop["id"], + "class": "IfcPropertySingleValue", + "value": "b", + "value_type": "IfcLabel", + } + }, + }, + } + } + class TestGetElementsUsingPset(test.bootstrap.IFC4): def test_run(self):