forked from 1b-agent/opencadstudio-upstream
fix(clipboard): copied XDATA keeps its application in another drawing
EED names its application by APPID handle. Copying between drawings (paste, COPYTO, block palette insert, REFEDIT) kept the source drawing's handles, so the saved DWG named APPIDs it did not have and the reference program refused to open it (xdata.cpp eInvalidInput). The copy now carries the APPID records its XDATA names, registers the missing ones, and re-points the EED at them. COPYTO also skipped every layer the target lacked (the check tested the source) and filled the target with the whole linetype catalog; it now copies the missing layers and loads only the linetypes used. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
d909bd0787
commit
218150c76a
5 files changed
+120
-9
No files matched your search
@@ -296,13 +296,21 @@ impl OpenCADStudio {
|
||||
// Copy the referenced layer definitions out of the source before the
|
||||
// target borrow starts (the two tabs never borrow together).
|
||||
let mut missing_layers: Vec<codec::tables::Layer> = Vec::new();
|
||||
// The APPIDs their XDATA names, so it is re-pointed at the target's.
|
||||
let deps = crate::app::ClipboardDeps {
|
||||
app_ids: crate::app::ClipboardDeps::capture(
|
||||
&self.tabs[source_index].scene.document,
|
||||
&cloned,
|
||||
)
|
||||
.app_ids,
|
||||
..Default::default()
|
||||
};
|
||||
{
|
||||
let source_document = &self.tabs[source_index].scene.document;
|
||||
for entity in &cloned {
|
||||
let layer = entity.common().layer.clone();
|
||||
if layer.is_empty()
|
||||
|| layer == "0"
|
||||
|| source_document.layers.contains(&layer)
|
||||
|| missing_layers.iter().any(|l| l.name == layer)
|
||||
{
|
||||
continue;
|
||||
@@ -317,7 +325,6 @@ impl OpenCADStudio {
|
||||
let mut created = Vec::new();
|
||||
{
|
||||
let scene = &mut self.tabs[target_index].scene;
|
||||
crate::io::linetypes::populate_document(&mut scene.document);
|
||||
for layer_record in &missing_layers {
|
||||
if !scene.document.layers.contains(&layer_record.name) {
|
||||
let mut layer_record = layer_record.clone();
|
||||
@@ -325,7 +332,13 @@ impl OpenCADStudio {
|
||||
let _ = scene.document.layers.add(layer_record);
|
||||
}
|
||||
}
|
||||
for entity in cloned {
|
||||
use crate::app::command_driver::clipboard::{eed_app_map, merge_app_ids, remap_eed_apps};
|
||||
merge_app_ids(&mut scene.document, &deps);
|
||||
let apps = eed_app_map(&scene.document, &deps);
|
||||
for mut entity in cloned {
|
||||
remap_eed_apps(&mut entity, &apps);
|
||||
let linetype = entity.common().linetype.clone();
|
||||
crate::io::linetypes::ensure_catalog_linetype(&mut scene.document, &linetype);
|
||||
created.push(format!("{:X}", scene.add_entity_clone(entity).value()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user