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 <noreply@anthropic.com>
(cherry picked from commit a3950ac191)
This commit is contained in:
Petru Conduraru
2026-07-09 14:37:58 +03:00
committed by Dion Moult
parent af762ca810
commit c4609a634c
@@ -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