From 0b877cbffc35c54502a93f57655fe86edd503abb Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Wed, 14 Oct 2026 13:13:48 +0300 Subject: [PATCH] XREF: keep layer 0 and Defpoints as the host's own A reference's layer 0 and Defpoints are not dependent symbols: its objects on them use the host's layers of those names, which are made from the reference's only when the host has none. Before, they became XREF|0 / XREF|Defpoints on load and XREF$0$0 on bind. Co-Authored-By: Claude Opus 5.5 --- src/io/xref.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/io/xref.rs b/src/io/xref.rs index d051e12c8..1b9a4b52c 100644 --- a/src/io/xref.rs +++ b/src/io/xref.rs @@ -880,6 +880,23 @@ fn import_xref_symbols( for layer in xref_doc.layers.iter() { let old = layer.name.clone(); + // Layer 0 and Defpoints are never dependent symbols: the reference's + // objects on them use the host's layer of the same name (made from + // the reference's when the host has none), on load and on bind. + if old == "0" || old.eq_ignore_ascii_case("Defpoints") { + if !doc.layers.contains(&old) { + let mut cloned = layer.clone(); + cloned.plotstyle_handle = host_plotstyle; + cloned.material = host_material; + cloned.flags.xref_dependent = false; + cloned.xref_block_record_handle = Handle::NULL; + cloned.set_handle(doc.allocate_handle()); + let _ = doc.layers.add(cloned); + } + let host = doc.layers.get(&old).map_or(old.clone(), |l| l.name.clone()); + maps.layers.insert(old.to_uppercase(), host); + continue; + } let new = naming.name_for(SymbolKind::Layer, &old); let mut cloned = layer.clone(); cloned.name = new.clone();