Skip to content

CAD to PDF: one page per sheet frame in model space (#535) - #2008

Draft
cre8ive-marketing wants to merge 1 commit into
KnifeLemon:mainfrom
cre8ive-marketing:feature/535-cad-frames
Draft

cre8ive-marketing wants to merge 1 commit into
KnifeLemon:mainfrom
cre8ive-marketing:feature/535-cad-frames

Conversation

@cre8ive-marketing

Copy link
Copy Markdown
Collaborator

Closes #535. Follows the plan on the issue, with your notes from the code.

What it does

  • When: only when CadSceneBuilder.BuildLayouts returns no sheets. A model-space drawing whose Layout1 holds only the viewport still splits by frames, and drawings with real layouts are unchanged (CAD → PDF: one page per paper-space layout, through its viewports (#172) #471).
  • Finding frames (CadSceneBuilder.Frames.cs): it looks at model-space entities on shown layers.
    • A closed, straight, axis-aligned four-corner LWPOLYLINE.
    • A block reference (not a MINSERT array) whose block's largest such rectangle becomes the frame. It is placed with the insert's own transform (base point, scale, rotation, normal), since the scene has expanded blocks by then.
  • A frame is a sheet when its size matches an ISO A4–A0 or ANSI A–E sheet, either way round, within 1 %:
    • It is compared in the drawing's $INSUNITS. A unitless drawing is tried as both millimetres and inches.
    • It can be at 1:1 or a usual drawing scale: metric 1:2 to 1:10000, and imperial ones like 1/4" = 1'-0" (48).
    • Random rectangles and A3-shaped ones at 3.3× don't count.
  • Nesting: a frame inside another frame is part of it. With fewer than two frames, model space stays one page as today.
  • Order: top row first (rows are frames level with each other), then left to right.
  • Rendering: each frame becomes a LayoutSheet with an empty paper scene and one ViewportView at 1:1 onto the frame. The existing CadRenderer.WritePdf(sheets, model, …) draws and clips it, so there's no second renderer. The view gets 0.25 % of room so the border line isn't clipped to half its width.
  • Paper size: frame pages use the preset's Pdf.PageSize through PageLayout.ForPdf, the same as layout pages, so an A3-default preset gives A3. I didn't switch to the detected sheet size.
  • Not found: frames drawn as four separate LINEs. They could be added later if people need them.
  • No setting and no schema step. The CHANGELOG (bullet plus a ko/en pair) and docs/ENGINES.md are updated.

Tests (CadFrameTests, DXF built with CadBuilder)

  • Reading order: three A3 frames, two on top and one below, give 3 sheets in reading order. An A4 frame inside the second one isn't a sheet of its own.
  • Through the converter: the same drawing, with Layout1 holding only a viewport, gives a 3-page PDF. Every page is A3 landscape, shows its frame's own line, and shows nothing from the frames next to it.
  • No sheet: rectangles of non-sheet size, A3 shapes at a non-scale and a single real frame all leave one page.
  • Inch drawing: title blocks inserted as ANSI B blocks, one at 1:1 and one turned and at 48×, are frames. The same drawing set to millimetres isn't.
  • Unitless drawing: A1 frames at 1:100 are frames.
  • All CAD test classes pass locally: Cad, CadColor, CadLayout, CadVersion, CadFrame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CAD to PDF: one page per title-block frame in model space

1 participant