From ae3b305f951024308b5a7dba79eecd39e1279ed1 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 21 Jun 2026 06:55:34 +0300 Subject: [PATCH] fix(dim): move the baked dimension block when the dimension is transformed A dimension's final graphics are baked into a per-instance *D block, and the render draws that block's sub-entities directly rather than the definition points. Move/rotate/scale/mirror updated the definition points but left the block sub-entities in place, so the dimension stayed drawn where it was. Apply the same transform to the dimension's *D block sub-entities. Co-Authored-By: Claude Opus 4.8 --- src/scene/mod.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 918df64df..ebbc240ba 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -5347,6 +5347,32 @@ impl Scene { } } } + // A dimension's final geometry is baked into a per-instance `*D` + // block, and the render draws those sub-entities directly (not the + // definition points). Transform them with the dimension, or it would + // stay drawn in place while only its def points move. + let dim_block_subs: Vec = handles + .iter() + .filter_map(|&h| match self.document.get_entity(h) { + Some(EntityType::Dimension(d)) => { + let bn = d.base().block_name.clone(); + if bn.trim().is_empty() { + None + } else { + Some(bn) + } + } + _ => None, + }) + .filter_map(|bn| { + self.document + .block_records + .iter() + .find(|br| br.name.eq_ignore_ascii_case(&bn)) + .map(|br| br.entity_handles.clone()) + }) + .flatten() + .collect(); for &h in handles { if let Some(entity) = self.document.get_entity_mut(h) { view::dispatch::apply_transform(entity, t); @@ -5384,6 +5410,12 @@ impl Scene { } } } + // Move the baked dimension-block sub-entities too (collected above). + for h in &dim_block_subs { + if let Some(entity) = self.document.get_entity_mut(*h) { + view::dispatch::apply_transform(entity, t); + } + } // Only the transformed entities changed (a top-level move/rotate/scale/ // mirror never edits a block definition) — re-tessellate just those and // keep the block cache + every other entity's memoized wires.