forked from 1b-agent/opencadstudio-upstream
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 <[email protected]>
This commit is contained in:
1 parent
960d51d955
commit
8820437fa4
2 files changed
+57
No files matched your search
@@ -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()
|
||||
|
||||
@@ -2728,6 +2728,13 @@ impl Scene {
|
||||
/// standard linetypes and a compatible page setup on every paper layout.
|
||||
pub fn populate_new_drawing_defaults(&mut self) {
|
||||
crate::io::linetypes::populate_document(&mut self.document);
|
||||
// A new drawing is metric, as the reference's ISO template: millimetre
|
||||
// insertion units, metric measurement, and the ISO-25 dimension style
|
||||
// current. Standard stays available for imperial work.
|
||||
self.document.header.measurement = 1;
|
||||
self.document.header.insertion_units = 4;
|
||||
crate::scene::creation_style::ensure_iso_dim_style(&mut self.document);
|
||||
self.document.header.current_dimstyle_name = "ISO-25".to_string();
|
||||
for obj in self.document.objects.values_mut() {
|
||||
if let acadrust::objects::ObjectType::Layout(l) = obj {
|
||||
if l.name != "Model" {
|
||||
|
||||
Reference in new issue
Block a user