Bonsai: duplicate-drawing share toggle only preserves already-shared annotations

The "Share Annotations" toggle shared every manual annotation on the source
drawing, which surprised users - a note unique to that drawing shouldn't
silently become a shared element on the copy.

It now preserves existing sharing only: an annotation already assigned to
more than one drawing stays shared with the duplicate, while annotations
unique to this drawing (and auto-generated tags) are still duplicated into
independent copies. The toggle is renamed "Keep Shared Annotations Shared"
to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ryan Schultz
2026-08-20 11:09:44 -05:00
parent 8285e62365
commit 2ce5ddc10b
2 changed files with 14 additions and 9 deletions
@@ -203,10 +203,11 @@ class DuplicateDrawing(bpy.types.Operator, tool.Ifc.Operator):
drawing: bpy.props.IntProperty()
should_duplicate_annotations: bpy.props.BoolProperty(name="Should Duplicate Annotations", default=False)
share_annotations: bpy.props.BoolProperty(
name="Share Annotations",
name="Keep Shared Annotations Shared",
description=(
"Assign the same annotations to the new drawing (shared - editing one updates both) "
"instead of creating independent copies. Auto-generated tags are always copied"
"Annotations already shared across multiple drawings stay shared with the new drawing "
"(editing one updates both) instead of being copied. Annotations unique to this drawing "
"are still duplicated"
),
default=False,
)
+10 -6
View File
@@ -370,12 +370,16 @@ def duplicate_drawing(
if should_duplicate_annotations:
source_annotations = [a for a in drawing_tool.get_group_elements(group) if a != drawing]
if share_annotations:
# Share manual annotations with the new drawing (multi-group membership):
# the same entity now belongs to both drawings' groups, so edits propagate.
# Auto-generated tags (grid/section/storey) can't be shared - they are
# regenerated per drawing - so they are still duplicated.
to_share = [a for a in source_annotations if not drawing_tool.is_auto_annotation(a)]
to_duplicate = [a for a in source_annotations if drawing_tool.is_auto_annotation(a)]
# Preserve existing sharing: an annotation that already appears on more
# than one drawing stays shared with the duplicate (the same entity is
# added to the new drawing's group, so edits keep propagating). Annotations
# unique to this drawing - and auto-generated tags - are duplicated as usual.
to_share = [
a
for a in source_annotations
if not drawing_tool.is_auto_annotation(a) and len(drawing_tool.get_annotation_drawings(a)) > 1
]
to_duplicate = [a for a in source_annotations if a not in to_share]
if to_share:
ifc.run("group.assign_group", group=new_group, products=to_share)
else: