diff --git a/src/bonsai/bonsai/tool/type.py b/src/bonsai/bonsai/tool/type.py index f2617ad060..6a212afb0f 100644 --- a/src/bonsai/bonsai/tool/type.py +++ b/src/bonsai/bonsai/tool/type.py @@ -107,7 +107,15 @@ class Type(bonsai.core.tool.Type): # RelatingType / RelatedObjects classes; the one-to-one class pairing # is a buildingSMART implementer agreement, not file-validation. schema = occurrence.file.schema - return relating_type.is_a() in ifcopenshell.util.type.get_applicable_types(occurrence.is_a(), schema=schema) + if relating_type.is_a() in ifcopenshell.util.type.get_applicable_types(occurrence.is_a(), schema=schema): + return True + # The implementer agreement map has no entry for the abstract + # IfcTypeProduct, which Bonsai uses for annotation types. The schema + # defines IfcTypeProduct.ApplicableOccurrence for exactly this purpose, + # so honor it. occurrence.is_a() handles subtypes and unknown tokens. + if applicable_occurrence := getattr(relating_type, "ApplicableOccurrence", None): + return occurrence.is_a(applicable_occurrence.split("/", 1)[0]) + return False @classmethod def has_material_usage(cls, element: ifcopenshell.entity_instance) -> bool: