diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index 170d1cc465..94a44c246a 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -333,9 +333,12 @@ def get_property( for prop in properties or []: if prop.Name != name: continue + is_single_value = False # For now we pass value type only for single values. if prop.is_a("IfcPropertySingleValue"): # 2 IfcPropertySingleValue.NominalValue result = v.wrappedValue if (v := prop[2]) else None + result_type = v.is_a() if v else None + is_single_value = True elif prop.is_a("IfcPropertyEnumeratedValue"): # 2 IfcPropertyEnumeratedValue.EnumerationValues result = [v.wrappedValue for v in values] if (values := prop[2]) else None @@ -355,6 +358,8 @@ def get_property( result = data if verbose: result = {"id": prop.id(), "class": prop.is_a(), "value": result} + if is_single_value: + result["value_type"] = result_type return result diff --git a/src/ifcopenshell-python/test/util/test_element.py b/src/ifcopenshell-python/test/util/test_element.py index 34d8020829..12a444b0a4 100644 --- a/src/ifcopenshell-python/test/util/test_element.py +++ b/src/ifcopenshell-python/test/util/test_element.py @@ -53,6 +53,7 @@ class TestGetPsetIFC4(test.bootstrap.IFC4): "id": 4, "class": "IfcPropertySingleValue", "value": "b", + "value_type": "IfcLabel", } def test_getting_the_psets_of_a_product_type_as_a_dictionary(self): @@ -66,6 +67,7 @@ class TestGetPsetIFC4(test.bootstrap.IFC4): "id": 3, "class": "IfcPropertySingleValue", "value": "y", + "value_type": "IfcLabel", }, "id": pset.id(), }