Bonsai: keep shared annotations when removing a drawing

remove_drawing deleted every element in the drawing's group, so an annotation
shared with other drawings was destroyed along with the drawing it was removed
from. It now excludes annotations that are still assigned to more than one
drawing from deletion; group.remove_group drops only this drawing's membership
rel, so the shared annotation stays on its other drawings. The drawing camera
and annotations unique to this drawing are still deleted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ryan Schultz
2026-08-20 11:58:52 -05:00
parent 9ad30c8051
commit 2739df8656
+13 -1
View File
@@ -438,7 +438,19 @@ def remove_drawing(
group = drawing_tool.get_drawing_group(drawing)
if group:
drawing_tool.delete_drawing_elements(drawing_tool.get_group_elements(group))
# Annotations shared with other drawings must survive this removal - only
# detach them from this drawing. group.remove_group drops this group's
# membership rel, so a shared annotation stays on its other drawings.
to_delete = [
e
for e in drawing_tool.get_group_elements(group)
if not (
e.is_a("IfcAnnotation")
and e.ObjectType != "DRAWING"
and len(drawing_tool.get_annotation_drawings(e)) > 1
)
]
drawing_tool.delete_drawing_elements(to_delete)
ifc.run("group.remove_group", group=group)
drawing_tool.import_drawings()