From 9d5ee75bcca433fcbb2d3f8bc77dd2e8399855f4 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 21 Jun 2026 13:20:16 +0300 Subject: [PATCH] fix(layout): place sheet viewport center in the paper plane (#156) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The overall (sheet) viewport was created with its center as (x, 0, z) — carrying the paper-height midpoint in z with y = 0. AutoCAD/TrueView read a paper-space viewport center as (x, y), so the sheet view ended up centered at y = 0, shifting the whole layout half a page down; activating the layout in AutoCAD could fault on the off-plane viewport. Store the center as (x, y, 0), matching the convention MVIEW already uses for floating viewports. Verified: a newly created paper-space viewport no longer faults AutoCAD on layout switch. Co-Authored-By: Claude Opus 4.8 --- src/scene/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 33e54798c..22b3b508a 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -1270,11 +1270,15 @@ impl Scene { let mut vp = acadrust::entities::Viewport::new(); vp.id = 1; vp.status = acadrust::entities::ViewportStatusFlags::default_on(); - // Paper plane is (x, z) with y = 0 (same convention MVIEW uses). + // Paper-space center is a 2D (x, y) point with z = 0 — the same + // convention MVIEW uses for floating viewports. AutoCAD/TrueView read + // the viewport center as (x, y); putting the paper-height midpoint in z + // (with y = 0) left the sheet view centered at y = 0, shifting the whole + // layout half a page down. See issue #156. vp.center = acadrust::types::Vector3::new( (min_lim.0 + max_lim.0) / 2.0, - 0.0, (min_lim.1 + max_lim.1) / 2.0, + 0.0, ); vp.width = pw; vp.height = ph;