Xref attach: Attach dialog, reference prompts, and xref drawings other applications can open

Attach External Reference dialog after XATTACH / ATTACH; ATTACH routes
drawings, PDFs and images; placement prompts and messages follow the
reference (presets, Corner/XYZ, nonzero check, existing definition reuse,
missing file, self-reference); name keeps the file's case; overlay and
path type at attach; one undo step for definition and INSERT; -XREF option
prompt and `?` table; XREF opens the palette; ER alias; xref Properties
rows; dependent symbols flagged and remapped and resolved content left out
of the saved file; dialog_ok automation action; localized labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-09-23 14:44:12 +03:00
1 parent f2d534bf71
commit 6bd55bc32e
44 files changed
+2514 -359

No files matched your search

+12 -55
View File
@@ -3127,60 +3127,17 @@ impl OpenCADStudio {
self.sync_dyn_fields();
self.refresh_area_preview(i);
}
CmdResult::CommitAndExit(mut entity) => {
// For XATTACH: ensure the xref block definition exists before
// committing the INSERT entity that references it.
// Extract path early to avoid borrow conflicts.
let xattach_path: Option<String> = {
let tab = &self.tabs[i];
if let Some(cmd) = tab.active_cmd.as_ref() {
if cmd.name() == "XATTACH" {
cmd.xattach_path()
} else {
None
}
} else {
None
}
};
if let Some(path) = xattach_path {
// XREF-Task6: the host drawing path lives in the tab
// (`current_path`), not in `Scene`, so the self-attach
// guard runs here via the pure `is_self_attach` helper.
let host_file = self.tabs[i].current_path.clone();
let host_base = host_file
.as_deref()
.and_then(|p| p.parent())
.map(|p| p.to_path_buf());
if let Some(host) = host_file.as_deref() {
if crate::modules::insert::xattach::is_self_attach(
host,
&path,
host_base.as_deref(),
) {
self.command_line.push_error(crate::t!("XATTACH: cannot attach the host drawing into itself.").as_ref());
self.tabs[i].scene.clear_preview_wire();
self.tabs[i].active_cmd = None;
self.tabs[i].snap_result = None;
self.restore_pre_cmd_tangent();
return Task::none();
}
}
let prepared_name = crate::modules::insert::xattach::prepare_xref_block(
&mut self.tabs[i].scene,
&path,
host_base.as_deref(),
);
// `prepare_xref_block` may suffix a colliding stem. The
// command was created before that collision was known, so
// retarget its pending INSERT to the actual new block.
if let acadrust::EntityType::Insert(insert) = &mut entity {
insert.block_name = prepared_name;
}
// Resolving the xref merged its layer / linetype tables
// into the document — mirror them into the Layers panel
// and ribbon dropdowns now, not on the next reopen (#407).
self.refresh_layer_panel();
CmdResult::CommitAndExit(entity) => {
// XATTACH: the definition and its INSERT are created together
// in one undo step.
let xattach_request = self.tabs[i]
.active_cmd
.as_ref()
.filter(|cmd| cmd.name() == "XATTACH")
.and_then(|cmd| cmd.xattach_request());
if let Some(request) = xattach_request {
self.commit_xref_attach(i, request, entity);
return Task::none();
}
let insert_block_name = match &entity {
acadrust::EntityType::Insert(ins) => Some(ins.block_name.clone()),
@@ -9274,7 +9231,7 @@ impl OpenCADStudio {
out
}
fn restore_pre_cmd_tangent(&mut self) {
pub(super) fn restore_pre_cmd_tangent(&mut self) {
if let Some(was_on) = self.pre_cmd_tangent.take() {
if !was_on {
self.snapper.enabled.remove(&crate::snap::SnapType::Tangent);