fix(layout): place sheet viewport center in the paper plane (#156)

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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-21 13:20:16 +03:00
1 parent c80cc3292c
commit 9d5ee75bcc
1 file changed
+6 -2
+6 -2
View File
@@ -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;