New "remove deep" function in the element util module. See #1228.

This commit is contained in:
Dion Moult
2021-01-24 14:32:04 +11:00
parent b68f490dbc
commit 900aa20e10
@@ -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: