From 5937ed4b63db49fcf5521d42f16c747ae12d5e46 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Fri, 24 Nov 2023 14:02:16 +1100 Subject: [PATCH] Fix #4034. Bug where abstract pset template applicabilities didn't apply to occurrences as well as types. --- src/ifcopenshell-python/ifcopenshell/util/pset.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/util/pset.py b/src/ifcopenshell-python/ifcopenshell/util/pset.py index 1690d29b43..579127605c 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/pset.py +++ b/src/ifcopenshell-python/ifcopenshell/util/pset.py @@ -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