mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-13 22:12:12 +00:00
Merge pull request #1191 from dylanmtaylor/codex/stencilcraft-dxf-wire
Add linear units to neutral DXF drawing writer
This commit is contained in:
2 files changed
+10
-1
No files matched your search
@@ -1478,6 +1478,13 @@ const MODEL: &str = "*Model_Space";
|
||||
const PAPER: &str = "*Paper_Space";
|
||||
|
||||
impl Drawing<'_> {
|
||||
/// Set `$LUNITS` without making callers construct low-level group tags.
|
||||
pub fn with_linear_units(mut self, units: i64) -> Self {
|
||||
self.header.retain(|(name, _)| !name.eq_ignore_ascii_case("$LUNITS"));
|
||||
self.header.push(("$LUNITS".into(), vec![Tag::i(70, units)]));
|
||||
self
|
||||
}
|
||||
|
||||
/// The whole file as tags, ending with `0 EOF`, and how many entities were left out
|
||||
/// ([`EntityKind::Other`], and a MULTILEADER before 2007 or an ACAD_TABLE before 2004, which it has no groups for: pass
|
||||
/// those in `raw_entities`).
|
||||
|
||||
@@ -596,7 +596,8 @@ fn the_file_around_the_content() {
|
||||
raw_objects: vec![Tag::s(0, "DICTIONARY"), Tag::s(5, "901"), Tag::s(330, "A")],
|
||||
raw_classes: vec![Tag::s(0, "CLASS"), Tag::s(1, "IMAGEDEF")],
|
||||
..Drawing::default()
|
||||
};
|
||||
}
|
||||
.with_linear_units(2);
|
||||
let (tags, skipped) = drawing.tags();
|
||||
assert_eq!(skipped, 1, "the entity with no groups to write");
|
||||
assert_eq!(tags.last().map(|t| (t.code, t.str())), Some((0, "EOF".to_string())));
|
||||
@@ -617,6 +618,7 @@ fn the_file_around_the_content() {
|
||||
assert_eq!((d.header.acadver().as_deref(), d.header.ltscale(), d.header.insunits()), (Some("AC1032"), 2.0, 6));
|
||||
assert_eq!(d.header.vars.iter().filter(|(n, _)| *n == "$INSUNITS" || *n == "$ACADVER" || *n == "$HANDSEED").count(), 3);
|
||||
assert_eq!(d.header.point("$EXTMAX"), Some([100.0, 50.0, 0.0]));
|
||||
assert_eq!(d.header.vars.iter().find(|(name, _)| *name == "$LUNITS").map(|(_, tags)| tags[0].i64()), Some(2));
|
||||
// Blocks, their records and the layouts that name them.
|
||||
let names = d.block_names();
|
||||
let block = d.block("DOOR").expect("the block");
|
||||
|
||||
Reference in new issue
Block a user