From 7b7622910c43a3ee9be9afb21b5e44215a85d1cf Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Fri, 1 May 2026 21:00:27 +0300 Subject: [PATCH] fix: apply world_offset when committing interactively created entities Commands receive click coordinates in local space (DXF coords minus world_offset) for camera precision. Without correction, entities were placed world_offset away from the clicked position in existing drawings that have a non-zero centroid (e.g. UTM-coordinate drawings). Re-add world_offset via acadrust::Transform::from_translation (f64 precision) in commit_entity before the entity is inserted into the DXF document. Paper-space entities are exempt as they use sheet coords. Fixes #11 Co-Authored-By: Claude Sonnet 4.6 --- src/app/properties.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app/properties.rs b/src/app/properties.rs index b1a3cbbf..e9f320e7 100644 --- a/src/app/properties.rs +++ b/src/app/properties.rs @@ -295,6 +295,19 @@ impl H7CAD { ); crate::scene::dispatch::apply_line_weight(&mut entity, self.ribbon.active_lineweight); + // Commands pick points in local space (camera coordinates with world_offset + // already subtracted). Re-add world_offset so the entity lands at the correct + // DXF coordinate. Skip for paper-space entities (they use sheet mm coords). + let is_paper = self.tabs[i].scene.current_layout != "Model"; + if !is_paper { + let wo = self.tabs[i].scene.world_offset; + if wo[0] != 0.0 || wo[1] != 0.0 || wo[2] != 0.0 { + let delta = acadrust::types::Vector3::new(wo[0], wo[1], wo[2]); + let t = acadrust::types::Transform::from_translation(delta); + entity.apply_transform(&t); + } + } + if matches!(&entity, acadrust::EntityType::Viewport(_)) && self.tabs[i].scene.current_layout != "Model" {