mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
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>
This commit is contained in:
committed by
Dion Moult
parent
6f90badda8
commit
a3950ac191
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user