From c4609a634cd96d29cb4d29d88ab59a517dd80c42 Mon Sep 17 00:00:00 2001 From: Petru Conduraru Date: Thu, 9 Jul 2026 14:37:58 +0300 Subject: [PATCH] util.element: read property sets inside an IfcPropertySetDefinitionSet (#6330) get_pset and get_psets assumed RelatingPropertyDefinition is a single property definition and read definition.Name directly. When it is an IfcPropertySetDefinitionSet (a defined type wrapping a list of property set definitions) that attribute access raised AttributeError, so an element whose psets are grouped in a set returned none of them. Unpack IfcPropertySetDefinitionSet into its members in both loops and process each one. Single property definitions and the psets_only and qtos_only filters are unchanged. Co-Authored-By: Claude Opus 4.8 (cherry picked from commit a3950ac191abc1dd4b517a58faffbf9f828cfb4a) --- .../ifcopenshell/util/element.py | 35 +++++++++++++------ 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index 44552bc287..deee8dd959 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -112,8 +112,14 @@ def get_pset( for relationship in is_defined_by: if relationship.is_a("IfcRelDefinesByProperties"): definition = relationship.RelatingPropertyDefinition - if definition.Name == name: - pset = definition + # IfcPropertySetDefinitionSet is a defined type wrapping a list + # of property set definitions, so unpack it into its members. + if definition.is_a("IfcPropertySetDefinitionSet"): + definitions = definition.wrappedValue + else: + definitions = (definition,) + pset = next((d for d in definitions if d.Name == name), None) + if pset: break if pset: @@ -221,15 +227,22 @@ def get_psets( for relationship in is_defined_by: if relationship.is_a("IfcRelDefinesByProperties"): definition = relationship.RelatingPropertyDefinition - if ( - psets_only - and not definition.is_a("IfcPropertySet") - and not definition.is_a("IfcPreDefinedPropertySet") - ): - continue - if qtos_only and not definition.is_a("IfcElementQuantity"): - continue - psets.setdefault(definition.Name, {}).update(get_property_definition(definition, verbose=verbose)) + # IfcPropertySetDefinitionSet is a defined type wrapping a list + # of property set definitions, so unpack it into its members. + if definition.is_a("IfcPropertySetDefinitionSet"): + definitions = definition.wrappedValue + else: + definitions = (definition,) + for definition in definitions: + if ( + psets_only + and not definition.is_a("IfcPropertySet") + and not definition.is_a("IfcPreDefinedPropertySet") + ): + continue + if qtos_only and not definition.is_a("IfcElementQuantity"): + continue + psets.setdefault(definition.Name, {}).update(get_property_definition(definition, verbose=verbose)) return psets