mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Migrate remove_deep to remove_deep2 across API modules
remove_deep is deprecated and can silently delete elements still in use. remove_deep2 requires zero inverses before removal, making it safer. Also fixes a double-removal bug in remove_grid_axis and prevents removing the last prop template from a pset template. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -51,8 +51,10 @@ def remove_context(file: ifcopenshell.file, context: ifcopenshell.entity_instanc
|
||||
new = context.ParentContext
|
||||
for inverse in file.get_inverse(context):
|
||||
if inverse.is_a("IfcCoordinateOperation"):
|
||||
# Trick to make sure the coordinate operation is not referenced
|
||||
# by a context so we can delete it safely
|
||||
inverse.SourceCRS = inverse.TargetCRS
|
||||
ifcopenshell.util.element.remove_deep(file, inverse)
|
||||
ifcopenshell.util.element.remove_deep2(file, inverse)
|
||||
else:
|
||||
ifcopenshell.util.element.replace_attribute(inverse, context, new)
|
||||
file.remove(context)
|
||||
|
||||
Reference in New Issue
Block a user