fix(clipboard): carry block-internal layers and refresh the layer panel

Cross-drawing paste recreated layers/linetypes/styles only for the
top-level selection, so objects inside a pasted block landed on layers the
target drawing didn't have. Scan the entities inside captured block
definitions for their dependencies too. Also refresh the layer panel after
a paste so the brought-in layers show in the manager and the dropdown.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-21 02:12:58 +03:00
1 parent 5f3eaa621c
commit e45064f8a8
2 files changed
+10 -2

No files matched your search

+3
View File
@@ -623,6 +623,9 @@ impl OpenCADStudio {
// render instead of staying invisible. (#135)
self.tabs[i].scene.populate_meshes_from_document();
self.tabs[i].dirty = true;
// Surface any layers the paste brought in (cross-drawing)
// in the layer manager and the layer dropdown.
self.refresh_layer_panel();
self.refresh_properties();
self.command_line
.push_info(&format!("{count} object(s) pasted."));
+7 -2
View File
@@ -684,7 +684,12 @@ impl ClipboardDeps {
|| n.eq_ignore_ascii_case("ByLayer")
|| n.eq_ignore_ascii_case("ByBlock")
};
for e in entities {
// Scan the copied entities AND the entities inside every captured
// block definition, so a block-internal object's layer / linetype /
// style is recreated too — not just the top-level selection's.
let blocks = Self::capture_blocks(doc, entities);
let block_entities = blocks.iter().flat_map(|d| d.entities.iter());
for e in entities.iter().chain(block_entities) {
let c = e.common();
if !c.layer.is_empty() {
layers.insert(c.layer.clone());
@@ -719,7 +724,7 @@ impl ClipboardDeps {
linetypes: ltypes.iter().filter_map(|n| doc.line_types.get(n).cloned()).collect(),
text_styles: tstyles.iter().filter_map(|n| doc.text_styles.get(n).cloned()).collect(),
dim_styles: dstyles.iter().filter_map(|n| doc.dim_styles.get(n).cloned()).collect(),
blocks: Self::capture_blocks(doc, entities),
blocks,
}
}