Fix #4034. Bug where abstract pset template applicabilities didn't apply to occurrences as well as types.

This commit is contained in:
Dion Moult
2023-11-24 14:02:16 +11:00
parent 8f650c56e5
commit 5937ed4b63
@@ -114,6 +114,19 @@ class PsetQto:
template_type = template_type or ""
if "TYPE" in template_type and ifcopenshell.util.schema.is_a(entity, "IfcTypeObject"):
types = ifcopenshell.util.type.get_applicable_types(applicable_class, "IFC4")
if not types:
# Abstract classes will not have an "applicable type" but
# the implementer agreement still applies to them.
occurrence_class = None
try:
occurrence_class = self.schema.declaration_by_name(applicable_class + "Type")
except:
try:
occurrence_class = self.schema.declaration_by_name("IfcType" + applicable_class[3:])
except:
pass
if occurrence_class:
types = [occurrence_class.name()]
for ifc_type in types:
if ifcopenshell.util.schema.is_a(entity, ifc_type):
return True