Skip to main content

Module layout

Module layout 

Source
Expand description

Sheet, scale and view placement, ported from draftwright’s layout authority (compose.choose_scale and compose._layout_geometry, ADR 2): each principal view is a block, its projected box plus the annotation bands reserved on each side, and the blocks are packed by box arithmetic (compose-then-pack). The isometric takes the largest empty rectangle the packed blocks and the title block leave.

The arithmetic is held to draftwright’s own calls by tests/layout.rs, which replays the layout calls recorded from Python builds (tools/capture_layout.py).

Not ported: the rear view (draftwright composes it through relative projection origins), and the automatic auto arrangement (not a production choice). First angle (Request::first_angle) mirrors the packed third-angle row and column (geometry), rather than draftwright’s origins.

Structs§

Attempt
One re-plan tried: its findings (None: it could not be planned) and whether it was taken.
Block
A view’s footprint: the half-extents of its projected box and the band reserved on each side.
CalloutBand
One authored callout column or row, measured in paper mm before view packing.
Findings
What a finished plan’s findings say of it, for the recovery: its hard layout failures (ink off the sheet, labels overlapping, a line through a label, an overflowing title field, views that do not fit) and the required items it lost for want of room.
Gdt
A feature control frame, datum feature symbol or label as the layout reserves for it (Strips::reserve_gdt), from dims::gdt::demand.
Geometry
Where everything sits, and whether it fits.
Lanes
The lanes the port’s own dimensions stack in beside each view (dims::lanes), by the strip they take: horizontal dimensions below the front and the side and above the plan, vertical ones right of the front and the side and left of the plan, callouts below the front and above the plan and the side.
Margins
Distances from the sheet edges, mm.
Measured
Measured blocks of an annotated drawing, for a repack: they may only widen the estimate.
Pick
A scale, a sheet, its title-block width and the arrangement it was chosen under.
Principals
Which principal views the sheet carries.
Request
Everything about the drawing the layout reads, apart from scale, sheet and arrangement.
Scaled
What depends on the scale: angular dimensions’ footprints about their view’s centre, and the derived (detail) views’ boxes.
Strips
The annotation bands reserved around the principal views, page mm (draftwright’s StripDepths). They come from the features to be dimensioned.

Enums§

Arrangement
Where the isometric goes relative to the orthographic row.
Corner
A table’s preferred corner.
Fallback
How the scale and sheet were reached when no standard choice fits.
Retry
A re-plan the automatic layout recovery tries (ISSUE-1299-a): a standard scale on the sheet already chosen, or a larger standard sheet at the scale its fixed-sheet rule picks.

Constants§

ANSI_PAGES
ANSI and architectural paper, exact inch dimensions expressed in millimetres.
ARCH_PAGES
AUTOMATIC_ARRANGEMENTS
The arrangements an automatic choice tries, in preference order.
FRAME
Page mm. The sheet edge margin, the title block’s inset (flush with the frame at its right and bottom edges, ISO 7200) and height, the annotation text height and its padding. The frame’s inset from the trimmed sheet edge (ISO 5457): the frame, title block, zones, centring marks and frame-corner tables are placed against it.
FRAME_GUTTER
The clear gutter every view and annotation keeps inside the frame (sheet/frame_gutter, maintainer 2026-10-25: 3 mm at least). Spare paper widens it further ([crate::view_gutters]).
GDT_CLEAR
The clearance dims::gdt keeps beyond a strip’s dimensions and between its tiers, mm.
INCH_SCALES
Decimal-inch mechanical and architectural ratios, in descending order.
MIN_LOC_SEP
The least page distance between two located ordinates on one axis (draftwright’s _MIN_LOC_SEP_MM: an arrow and a pad), and the least page span of a location.
MIN_LOC_SPAN
MIN_STEP_DIM
The least page height a step must stand above the part’s base to carry a dimension (text, two arrows, two text gaps), and the least page distance between two dimensioned steps.
MIN_STEP_SEP
PAGES
ISO 216 sheets, smallest first: name, width, height (mm, landscape).
PLAN_HALO
The balloon standoff ring around a plan whose holes are tabulated (draftwright’s _balloon_halo): the first-line gap, one balloon (diameter three text heights) and a spacing.
RADIAL_REACH
The end-on radial fan’s reach beside the overall-height slot, for a Y-axis boss or step.
SCALES
ISO 5455’s scales, largest first, as draftwright tries them.
TB_CLEAR
TB_H
UPSCALE_TRIALS
The larger scales a required loss tries on the chosen sheet (draftwright’s _AUTOMATIC_UPSCALE_TRIAL_LIMIT), and the scales each way a hard layout failure tries (_AUTOMATIC_VALIDITY_SCALE_TRIAL_LIMIT): each try is a whole plan.
VALIDITY_TRIALS

Functions§

choose
Chooses the scale, sheet and arrangement as draftwright does (compose.choose_scale):
converge_steps
Chooses the scale with a step band that matches the steps legible at it (draftwright’s _converge_step_sizing): seeded with every step, re-gated at each chosen scale until the count repeats; a cycle reserves the largest count tried. measure gives the bands for a step count, pick the choice for them, count the legible steps at a scale.
crowded_locations
How many of one view axis’s located ordinates (distances from the datum) are illegible at scale by draftwright’s measure (_discard_short_refs, _legible_locations): a nonzero span under MIN_LOC_SPAN on the page, or one under MIN_LOC_SEP past the last legible one. draftwright drops those (location_ref_dropped, a required loss); the port keeps every location (LINT-hole_coverage-location), so for it this counts witness lines too close to read.
dim_pad
The base corridor between views: one first-line gap and one dimension tier (20 mm; 17 mm at compact spacing).
fit_box
Places a w × h box in region clear of obstacles (each inflated by clearance), as near the prefer corner as it can go: its lower-left corner, or none. Draftwright’s fit_box: candidates are flush with a region or obstacle edge, tried nearest first.
front_hole_rows_depth
The rows of Y-axis hole leaders below the front (draftwright’s front_hole_below band).
geometry
Lays the views out at scale on a page_w × page_h sheet with a tb_w title block.
gutter
The current plan’s frame gutter, mm.
iso_factor
How much the isometric is scaled relative to the sheet to fill its rectangle (draftwright’s _fit_iso_view with no annotation obstacles), given the projected iso’s box relative to the view’s centre at the sheet scale. One when it is left at sheet scale.
iso_factor_with_detail
Python _fit_iso_view: a fitting sheet-scale iso stays at that scale when a detail claims space. An overflowing iso must still shrink.
keep_sheet_scale
Preserve Python _fit_iso_view’s strict 5 % no-op band in measured refits too. The band applies to both shrink and grow factors; a tiny overflow is kept and reported.
lane_band
The band lanes stacked lanes need: the first line’s gap, the lanes, and the outermost one’s reach; none for none.
lane_strip_depth
The same ladder at the port’s own lane pitch (lane_band): its vertical dimensions stack at crate::dims::lane_pitch with their labels turned along the dimension line, so the ladder itself takes this much and right_strip_depth’s slots are two to three times it. Sizing reserves this band only for a sheet trial whose slot-sized drawing does not fit (demand::size_with_details).
largest_empty_rect
The largest empty rectangle of drawable that overlaps no obstacle, maximising the uniform scale of target ([1, 1]: the largest square it holds). The whole drawable when there is none. Draftwright’s _largest_empty_rect, with its deterministic winners.
legible_steps
The step levels worth dimensioning at scale (draftwright’s _legible_steps): each at least MIN_STEP_DIM above the base on the page and MIN_STEP_SEP above the last one kept.
margin
Views and annotation ink keep this far inside the trimmed sheet edge: the frame plus the current plan’s gutter ([with_gutter]).
plan_above_depth
The tiers above the plan for X-location dimensions, one per distinct reference and one spare (draftwright’s _est_pv_above_depth); none without references.
plan_sheet
Pack auxiliary blocks as wrapping rows, after the sheet’s corner tables. Blocks include caption/scale/cross-reference bands; no notes or projection furniture are reserved here.
recover
draftwright’s bounded, ordered recovery on a finished drawing (builder._AutomaticResolution, recover_hard_layout and recover_required_no_iso), for a plan at scale on page whose findings are first:
right_strip_depth
The band right of the front view for its height ladder (draftwright’s _est_right_strip_depth): the overall height’s slot, then one slot per step level and per other occupant (an axial boss height).
title_block_width
The title block’s width for a sheet: 120 mm on A4, 150 mm on A3 and larger.

Type Aliases§

Rect
[x0, y0, x1, y1], page mm.