forked from 1b-agent/opencadstudio-upstream
fix(clipboard): paste copies dimensions correctly (#290)
Copy-paste (CTRL+C / CTRL+V) dropped dimensions. A dimension draws from its baked *D block, whose geometry is in absolute WCS coordinates, and the clipboard paste path added the dimension entity but never gave it its own transformed block — unlike the in-drawing COPY, which does (#161). So the pasted dimension kept pointing at the source block and rendered at the original location instead of the paste point (same drawing), or had no block at all (cross-drawing). Capture each copied dimension's *D block into the clipboard, and on paste build a fresh transformed copy of it and re-point the dimension's block_name — for same- and cross-drawing pastes alike. Factored the block-building out of clone_transformed_block into a shared define_transformed_block, and the block snapshotting out of capture_blocks into snapshot_block.
This commit is contained in:
1 parent
fd0b8fc1d4
commit
c20f277e54
3 files changed
+121
-34
No files matched your search
@@ -2012,6 +2012,35 @@ impl OpenCADStudio {
|
||||
if let Some(t) = &translate {
|
||||
crate::scene::view::dispatch::apply_transform(&mut entity, t);
|
||||
}
|
||||
// A dimension draws from its baked `*D` block (baked in WCS), so
|
||||
// give the paste its own transformed copy of that block and
|
||||
// re-point it — otherwise the pasted dimension renders at the
|
||||
// source location instead of the paste point. The block was
|
||||
// snapshotted into the clipboard at copy time, so this works
|
||||
// cross-drawing too. Mirrors the in-drawing copy. (#290, #161)
|
||||
if let acadrust::EntityType::Dimension(d) = &entity {
|
||||
let bn = d.base().block_name.clone();
|
||||
if !bn.trim().is_empty() {
|
||||
let subs = self
|
||||
.clipboard_deps
|
||||
.dim_blocks
|
||||
.iter()
|
||||
.find(|b| b.name.eq_ignore_ascii_case(&bn))
|
||||
.map(|def| def.entities.clone());
|
||||
if let Some(subs) = subs {
|
||||
let bt = translate.clone().unwrap_or(
|
||||
crate::command::EntityTransform::Translate(glam::DVec3::ZERO),
|
||||
);
|
||||
if let Some(new_bn) =
|
||||
self.tabs[i].scene.define_transformed_block(&subs, &bt)
|
||||
{
|
||||
if let acadrust::EntityType::Dimension(d) = &mut entity {
|
||||
d.base_mut().block_name = new_bn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self.tabs[i].scene.add_entity_clone(entity)
|
||||
})
|
||||
.collect();
|
||||
|
||||
Reference in new issue
Block a user