diff --git a/src/entities/dimension.rs b/src/entities/dimension.rs index ad75c60af..c0a78c529 100644 --- a/src/entities/dimension.rs +++ b/src/entities/dimension.rs @@ -1756,6 +1756,12 @@ pub(crate) fn resolved_dimension_style( } } + // An annotative style sizes its features by the annotation scale; the + // DIMSCALE it still stores is inert. + if style.annotative { + style.dimscale = 0.0; + } + // Negative DIMLFAC applies only in paper space, and there only to a // dimension that measures model space through a viewport. The associative // record stores the applied factor; zero marks paper-space geometry whose diff --git a/src/scene/mod.rs b/src/scene/mod.rs index fa56c3c69..47f988779 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -5654,11 +5654,30 @@ impl Scene { 4 // Millimeters }; - crate::modules::draw::units::conversion_factor( + let factor = crate::modules::draw::units::conversion_factor( self.document.header.insertion_units, paper_unit, ) - .unwrap_or(1.0) + .unwrap_or(1.0); + // Some templates store their ratio scales already converted to the + // drawing unit (a metre drawing's "1:50" as 1 paper = 0.05 drawing). + // Those must not be converted a second time. + let converted = self.document.objects.values().find_map(|object| { + let ObjectType::Scale(scale) = object else { + return None; + }; + let (paper, drawing) = scale.name.split_once(':')?; + let paper = paper.trim().parse::().ok()?; + let nominal = drawing.trim().parse::().ok()? / paper; + let stored = scale.drawing_units / scale.paper_units; + (nominal.is_finite() && nominal > 0.0) + .then(|| (stored * factor - nominal).abs() <= 1.0e-6 * nominal) + }); + if factor != 1.0 && converted == Some(true) { + 1.0 + } else { + factor + } } fn is_architectural_scale_name(name: &str) -> bool {