mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 06:52:39 +00:00
Experimental proposed deep removal. See #1812.
This commit is contained in:
@@ -136,6 +136,23 @@ def remove_deep(ifc_file, element):
|
|||||||
ifc_file.unbatch()
|
ifc_file.unbatch()
|
||||||
|
|
||||||
|
|
||||||
|
def remove_deep2(ifc_file, element):
|
||||||
|
# Experimental remove deep proposal. No batch for now until this is more certain. See #1812.
|
||||||
|
# ifc_file.batch()
|
||||||
|
to_delete = set()
|
||||||
|
subgraph = list(ifc_file.traverse(element, breadth_first=True))
|
||||||
|
subgraph_set = set(subgraph)
|
||||||
|
subelement_queue = ifc_file.traverse(element, max_levels=1)
|
||||||
|
while subelement_queue:
|
||||||
|
subelement = subelement_queue.pop(0)
|
||||||
|
if subelement.id() and len(set(ifc_file.get_inverse(subelement)) - subgraph_set) == 0:
|
||||||
|
to_delete.add(subelement)
|
||||||
|
subelement_queue.extend(ifc_file.traverse(subelement, max_levels=1)[1:])
|
||||||
|
for subelement in to_delete:
|
||||||
|
ifc_file.remove(subelement)
|
||||||
|
# ifc_file.unbatch()
|
||||||
|
|
||||||
|
|
||||||
def copy(ifc_file, element):
|
def copy(ifc_file, element):
|
||||||
new = ifc_file.create_entity(element.is_a())
|
new = ifc_file.create_entity(element.is_a())
|
||||||
for i, attribute in enumerate(element):
|
for i, attribute in enumerate(element):
|
||||||
|
|||||||
Reference in New Issue
Block a user