diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index ddab485dc1..f947dccfc0 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -118,6 +118,14 @@ def is_representation_of_context(representation, context, subcontext=None, targe return True +def remove_deep(ifc_file, element): + subgraph = list(ifc_file.traverse(element)) + subgraph_set = set(subgraph) + for ref in subgraph[::-1]: + if ref.id() and len(set(ifc_file.get_inverse(ref)) - subgraph_set) == 0: + ifc_file.remove(ref) + + def get_representation(element, context, subcontext=None, target_view=None): if element.is_a("IfcProduct") and element.Representation: for r in element.Representation.Representations: