Repository navigation
CAD → PDF: one page per paper-space layout, through its viewports (#172) - #471
Conversation
…ifeLemon#172) A drawing with layouts becomes a PDF with one page per layout that has something on it, in tab order: model space is drawn through each viewport at its scale, clipped to the frame, under the layout's own drawing. Images and SVG stay one picture of model space; drawings without layouts are unchanged.
KnifeLemon
left a comment
There was a problem hiding this comment.
Thanks @cre8ive-marketing, this is the first step from #172 and it reads well: one page per layout in tab order, the sheet's own viewport skipped, model space built once and clipped to each viewport, images and SVG unchanged, and the limits written in ENGINES.md. Two things before it goes in:
- The view centre is in display coordinates.
Viewport.ViewCenteris DCS (DXF 12/22), and DCS has its origin at the view target (ViewTarget, DXF 17/27/37, in WCS). For a view from the top, the model point in the middle of the viewport isViewTarget + ViewCenter. Most drawings have the target at 0,0,0, which is why the test passes, but a drawing with another target shows the wrong part of model space. Please add the target, and a test with a non-zero one. - Drawings made only in model space. AutoCAD gives a layout a viewport the first time its tab is opened, so many model-space-only drawings have a Layout1 that holds just that viewport, with the view it had back then. Those used to give one page of the whole model space; now they give the Layout1 page, which shows only part of the drawing if it grew afterwards. Could you keep the single model-space page when no layout has anything of its own besides viewports (no border, title block or notes), with a test for it? A layout with a title block keeps the new behaviour.
Smaller:
- A viewport that's switched off (
ViewportStatusFlags.ViewportOff) shows nothing in AutoCAD and could be skipped. - A viewport looking from another direction (
ViewDirectionnot 0,0,1) is drawn from the top; worth adding to the "Not followed" list in ENGINES.md.
Thanks!
…re off Review of KnifeLemon#471: - The model point at a viewport's centre is ViewTarget + ViewCenter (DCS has its origin at the target), with a test using a non-zero one. - When no layout has anything of its own besides viewports, the PDF stays one page of all of model space, as before: AutoCAD's Layout1 with only its first viewport no longer cuts the drawing. - Viewports that are off are skipped. - ENGINES.md: views from another direction are drawn from the top.
|
Thanks @KnifeLemon, all four are done in the latest commit:
All 39 CAD tests pass locally. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When model space has nothing visible, the one-picture scene falls back to the active layout's paper space. The per-layout PDF passed that scene as model space, so the layout's own border and notes were drawn a second time inside every viewport. Use an empty model scene in that case, with a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re/cad-layout-pages
|
The linux-arm64 portable job failed twice on 80ea676, in I merged current |
What does this change?
#172, the first step you described there: CAD → PDF with one page per paper-space layout, following each layout's viewports. Detecting title-block frames in model space isn't part of it.
Before: a DWG/DXF became one PDF page of model space. A drawing with an empty model space got its active layout instead, and viewports weren't followed.
Now (PDF only):
How:
CadSceneBuilder.BuildLayoutsbuilds aLayoutSheetper layout: its paper-space scene plus itsViewportViews (frame, view centre, scale). It skips the viewport that is the sheet itself (RepresentsPaper).CadRenderer.WritePdf(sheets, model, …)draws model space once per viewport throughPageLayout.Through(same page, the viewport's scale and centre) inside aClipRect, then draws the layout on top.Unchanged: SVG and images stay one picture of model space. DWG ↔ DXF is untouched.
Not followed yet (written in
docs/ENGINES.md):No settings change, no new strings, no new dependency. Only ACadSharp and SkiaSharp, which were already used.
How was it tested?
dotnet format --verify-no-changesdotnet testwith FFmpeg 9.0.2 and rhwp 0.8.7: Platform 48, Core 501, Cli 27, Setup 149, Engines 1596, App 847 pass, none fail.CadLayoutTests, with a drawing built in the test: a square and, far away, a circle in model space; two layouts, each with a border and one viewport ("Plan" at 1:1 on the square, "Detail" at 2:1 on the circle).CadBuilder.Sample(), which has only the default layout, gets no sheets.Screenshots
Page 1 (Plan, 1:1) and page 2 (Detail, 2:1) of the test drawing's PDF:
Checklist
src/Filee.App/Assets/i18n/*.jsonfiles (none added)THIRD-PARTY-NOTICES.md(none)Addresses #172 (one page per layout). Frame detection in model space can stay open there.