Metric new drawings with the ISO-25 dimension style current

A new drawing is metric (measurement 1, millimetre insertion units) and
carries the reference's ISO-25 dimension style as its current style, so
dimensions and annotational constraints draw at readable metric sizes
instead of Standard's imperial 0.18 text.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
ramox81andClaude Fable 5.1 committed 2026-09-22 12:29:38 +03:00
1 parent 960d51d955
commit 8820437fa4
2 files changed
+57

No files matched your search

+50
View File
@@ -35,6 +35,56 @@ fn named_text_style(doc: &CadDocument, name: &str) -> Option<TextStyle> {
.cloned()
}
/// Adds the reference's ISO-25 dimension style (the current style of its
/// metric template) when the drawing has none of that name.
pub fn ensure_iso_dim_style(doc: &mut CadDocument) {
if doc
.dim_styles
.iter()
.any(|style| style.name.eq_ignore_ascii_case("ISO-25"))
{
return;
}
let mut style = DimStyle::new("ISO-25");
style.handle = doc.allocate_handle();
style.dimtxt = 2.5;
style.dimasz = 2.5;
style.dimcen = 2.5;
style.dimexe = 1.25;
style.dimexo = 0.625;
style.dimgap = 0.625;
style.dimdli = 3.75;
style.dimtad = 1;
style.dimtih = false;
style.dimtoh = false;
style.dimtofl = true;
style.dimtix = false;
style.dimsoxd = false;
style.dimdsep = i16::from(b',');
style.dimlunit = 2;
style.dimdec = 2;
style.dimtdec = 2;
style.dimaunit = 0;
style.dimadec = 0;
style.dimazin = 0;
style.dimzin = 8;
style.dimtzin = 8;
style.dimatfit = 3;
style.dimtmove = 0;
style.dimscale = 1.0;
style.dimlfac = 1.0;
style.dimtfac = 1.0;
style.dimaltf = 0.03937007874016;
style.dimaltd = 3;
style.dimalttd = 3;
style.dimaltu = 2;
style.dimfxl = 1.0;
style.dimjogang = std::f64::consts::FRAC_PI_2;
style.dimmzf = 100.0;
style.dimaltmzf = 100.0;
let _ = doc.dim_styles.add(style);
}
fn named_dim_style(doc: &CadDocument, name: &str) -> Option<DimStyle> {
doc.dim_styles
.iter()