From 1ae118b1bb4be030e2e1e0ff2372ebd2cd7e1faf Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Thu, 15 Oct 2026 03:16:33 +0300 Subject: [PATCH] annotation: annotative dimstyles ignore DIMSCALE; unit-converted scales An annotative dimension style still stores a DIMSCALE (100 in ACA templates), but its features are sized by the annotation scale. Using the stored value drew 3 mm dimension text 300 units tall, burying the plan under giant digits. Some templates also store their ratio scales already converted to the drawing unit (a metre drawing's "1:50" as 1 paper = 0.05 drawing, with CANNOSCALEVALUE 20). Applying the INSUNITS conversion on top shrank the annotation multiplier a thousandfold. Co-Authored-By: Claude Opus 5.5 --- src/entities/dimension.rs | 6 ++++++ src/scene/mod.rs | 23 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) 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 {