forked from 1b-agent/opencadstudio-upstream
fix(blocks): a dynamic block copied to another drawing stays dynamic (#1816)
Only the definition's entities crossed drawings: its record's object graph (parameters, visibility states, grips) stayed behind, and a reference showing an evaluated copy lost the link to its definition. The clipboard now captures the graph and the dynamic definition of an evaluated reference, and paste and the block palette's insert-from-file recreate them on the new records, re-pointing members and element tags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca408f4329
commit
091331f3bd
6 files changed
+109
-21
No files matched your search
+16
-2
@@ -1916,6 +1916,10 @@ pub struct BlockDef {
|
||||
pub name: String,
|
||||
pub base_point: codec::types::Vector3,
|
||||
pub entities: Vec<codec::EntityType>,
|
||||
/// The source drawing's record, which other captured graphs name.
|
||||
pub source: codec::Handle,
|
||||
/// The record's object graph: a dynamic block's parameters and states.
|
||||
pub graph: Option<codec::BlockGraph>,
|
||||
}
|
||||
|
||||
/// The extension-dictionary object graph captured for one copied entity.
|
||||
@@ -2131,8 +2135,16 @@ impl ClipboardDeps {
|
||||
let mut queue: Vec<String> = Vec::new();
|
||||
for e in entities {
|
||||
if let EntityType::Insert(ins) = e {
|
||||
if seen.insert(ins.block_name.clone()) {
|
||||
queue.push(ins.block_name.clone());
|
||||
// A reference showing an evaluated copy needs its dynamic
|
||||
// definition too.
|
||||
let definition = doc
|
||||
.dynamic_definition_for_insert(ins.common.handle)
|
||||
.and_then(|h| doc.block_records.iter().find(|r| r.handle == h))
|
||||
.map(|record| record.name.clone());
|
||||
for name in std::iter::once(ins.block_name.clone()).chain(definition) {
|
||||
if seen.insert(name.clone()) {
|
||||
queue.push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2182,6 +2194,8 @@ impl ClipboardDeps {
|
||||
name: name.to_string(),
|
||||
base_point,
|
||||
entities: owned,
|
||||
source: br.handle,
|
||||
graph: doc.export_block_graph(br.handle),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user