Fix get_property_unit() crash on IfcPropertySingleValue.NominalValue = None

NominalValue is optional -- IfcPropertySingleValue permits a null value --
but get_property_unit() unconditionally accessed prop.NominalValue.is_a(),
crashing on any single-value property that's legitimately blank.

Also adds a regression test confirming IfcContextDependentUnit symbols
("each", "boxes", etc.) aren't shadowed by the IfcDerivedUnit branch added
in the previous commit.
This commit is contained in:
Richard Brice
2026-08-10 11:01:35 -07:00
parent 20a6c73fbf
commit 0e8d0ee845
2 changed files with 15 additions and 1 deletions
@@ -525,7 +525,8 @@ def get_property_unit(
entity = prop.declaration
measure_class = entity.attribute_by_index(3).type_of_attribute().declared_type().name()
elif prop.is_a("IfcPropertySingleValue"):
measure_class = prop.NominalValue.is_a()
if value := prop.NominalValue:
measure_class = value.is_a()
elif prop.is_a("IfcPropertyEnumeratedValue"):
if prop.EnumerationReference:
if unit := prop.EnumerationReference.Unit: