diff --git a/src/ifcopenshell-python/ifcopenshell/util/classification.py b/src/ifcopenshell-python/ifcopenshell/util/classification.py index 5d095a4052..a372dd7046 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/classification.py +++ b/src/ifcopenshell-python/ifcopenshell/util/classification.py @@ -27,7 +27,7 @@ def get_references(element: ifcopenshell.entity_instance, should_inherit=True) - references := getattr(element, "HasExternalReference", None) ) is not None: return {r.RelatingReference for r in references} - if should_inherit: + if should_inherit and element.is_a("IfcObject"): element_type = ifcopenshell.util.element.get_type(element) if element_type and element_type != element: results = get_references(element_type) diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index 670c8a9953..95c1031ae1 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -500,7 +500,7 @@ def get_type(element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity Note: `get_type(type_element) == type_element`. - :param element: The element occurrence + :param element: The element occurrence (IfcObject) :type: ifcopenshell.entity_instance :return: The related type element :rtype: Union[ifcopenshell.entity_instance, None] @@ -517,11 +517,11 @@ def get_type(element: ifcopenshell.entity_instance) -> Union[ifcopenshell.entity schema = element.file.schema if schema != "IFC2X3": - if is_typed_by := getattr(element, "IsTypedBy", []): + if is_typed_by := getattr(element, "IsTypedBy", ()): return is_typed_by[0].RelatingType return - if is_defined_by := element.IsDefinedBy: # IFC2X3 + if is_defined_by := getattr(element, "IsDefinedBy", ()): # IFC2X3 for relationship in is_defined_by: if relationship.is_a("IfcRelDefinesByType"): return relationship.RelatingType