mirror of
https://github.com/storytold/cadcraft.git
synced 2026-10-24 10:56:51 -06:00
INSERT from a file brings the file's multiline styles (#1639)
Inserting a DWG/DXF as a block merged its layers, linetypes and text, dimension, multileader and table styles, but not its multiline styles. A drawing that brings its wall styles in by inserting a library file (AutoLISP add-ons do this: INSERT walls.dwg, ERASE the reference, then MLINE with one of its styles) got "Cannot find multiline style". The styles now merge like the other tables: a name the drawing already has keeps the drawing's definition. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
bbbf4465c4
commit
15147260c1
@@ -149,6 +149,7 @@ fn merge_tables(d: &mut Drawing, src: &Drawing) {
|
||||
merge(&mut d.dim_styles, &src.dim_styles, |t| &t.name);
|
||||
merge(&mut d.mleader_styles, &src.mleader_styles, |t| &t.name);
|
||||
merge(&mut d.table_styles, &src.table_styles, |t| &t.name);
|
||||
merge(&mut d.mline_styles, &src.mline_styles, |t| &t.name);
|
||||
}
|
||||
|
||||
/// Which source blocks to copy, and under which name: new names keep theirs, generated
|
||||
@@ -255,4 +256,17 @@ mod tests {
|
||||
assert_eq!(file_ref(&s, "C:\\parts\\bolt.dxf").map(|f| f.name), Some("bolt".into()));
|
||||
assert!(file_ref(&s, "BOLT").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inserted_file_brings_its_mline_styles() {
|
||||
let mut src = Drawing::default();
|
||||
src.mline_styles.push(cadcraft_doc::MLineStyle { name: "WALL".into(), ..Default::default() });
|
||||
let mut d = Drawing::default();
|
||||
merge_tables(&mut d, &src);
|
||||
assert!(d.mline_styles.iter().any(|m| m.name == "WALL"));
|
||||
// A style this drawing already has keeps its own definition.
|
||||
let before = d.mline_styles.len();
|
||||
merge_tables(&mut d, &src);
|
||||
assert_eq!(d.mline_styles.len(), before);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user