Skip to main content

Crate draftwright

Crate draftwright 

Source
Expand description

Draftwright: automated technical drawings from STEP B-rep — Rust port.

Drawing logic only: the geometry (projection with hidden lines, sections) comes from the haecceity kernel, and feature recognition from quiddity.

Re-exports§

pub use session::Session;
pub use haecceity;

Modules§

api
The operations every adapter calls (ADR R1): the command line, the JSON-lines service (draftwright serve) and the MCP server (draftwright-mcp) are thin layers over these.
arc
Exact trimmed circular profiles shared by callout placement and leader lint.
blends
Blend ownership and exact-face attachment evidence, shared by planning and coverage.
bom
File-stated BOM facts. This reader uses the same P21 document access as PMI UDAs; it does not recognise shapes or allocate numbers. Only the saved part.process answer is read, to resolve manufacturing process before pack grouping.
bridge
The bridge from Python quiddity: its recognition JSON, written by tools/recognise.py, read into the Analysis’s features until Rust quiddity recognises them itself ([docs/model.md]).
broken
A single, geometry-proven longitudinal interruption. Measurements never use this map.
callouts
Shared manufacturing presentation and font-measured, word-preserving callout wrapping.
centrelines
ISO 128 chain-line furniture, resolved in page mm before annotation placement.
characteristics
File-owned inspection numbers, their final drawing carriers and inspection rings.
completeness
Bounded completeness: Analysis face claims and recognised features without drawn dimensions. Neither count proves recognition recall or manufacturing readiness.
cosmetic
Conventional representations drawn over a turned step’s outline: an external thread per ISO 6410-1 (a thin continuous line at the minor diameter over the thread length) and a knurl per the usual simplified convention (ISO 13444’s knurled surface shown by a few thin lines over part of its length: straight along the axis, diamond crossed at 30°). Python draftwright draws neither (its threads are cosmetic and unrecognised); the port draws them for the AP242 threads and knurls crate::pmi_lowering::manufacturing gives to a turned step (draftwright-rust #23).
demand
What the sheet must make room for, read from the Analysis before the views are placed: draftwright’s sheet-demand planning (analysis._plan_sheet_demand, compose._compose_anno_boxes, builder._automatic_turned_principals and planner.plan_sections) as far as the bridged features carry it.
detail
Enlarged orthographic regions, planned as late furniture before the isometric. Python: _core.DetailRequest, analysis.automatic*_detail_footprints and annotations.sections._resolve_details. The Rust kernel has no solid Booleans: the detail clips the source projection, retaining exact curve intervals rather than manufacturing a cut face. Bounds and recovered dimension IDs remain in the plan.
dimension_scheme
Authored scheme intent; independent model-space station evidence lives on Analysis.
dims
Dimensions and hole callouts: what the sheet states about sizes, planned from the Analysis’s features and drawn only from the plan (ADR R1 invariant 2).
evaluation
Observed drawing-consumer coverage (Python #1202): size evidence comes from the actual rendered sheets. Recognition supplies the denominator; an unsuccessful build is unknown, never supported by a capability declaration or treated as a successful empty drawing.
finding
Finding labels only: independent of drawing, planning and recovery policy.
fixes
Proportionate remedies. Local offers constrain paper, scale and sheet count.
gears
Authored metric external spur gears: Python model/ir.py:953 and annotations/gears.py. Only the author supplies normative data. Full-wire recognition remains lint evidence.
graphical_pmi
Triage graphical source evidence once on the finished plan, after layout selection.
half_section
Half sections (ISO 128-50 half view, half section): a part turned whole whose inside a section shows more cleanly than hidden lines (a coaxial hole with a counterbore, spotface or countersink, a bore that changes diameter along the axis, an internal groove, or a through bore under an outer groove, as on a bush or linear bearing) has its profile view drawn half as seen and half cut, split on the turning axis, so the internal steps and walls read as section edges rather than overlapping hidden lines. A plain bore under a plain or merely stepped outline stays a plain view: its hidden lines already read cleanly.
hole_table
Drop and escalate (the maintainer’s decision of 2026-10-09: draftwright’s _prepare_hole_table_run): a hole callout or hole location the placement could not put on the sheet is dropped and reported, and the drop escalates to a plan-view hole table with balloons.
iso_caption
The isometric’s required scale disclaimer, planned before free late furniture. Python: projection._fit_iso_view, builder’s post-fit furniture, and annotations._placement_occupancy.place_iso_nts_note.
items
Plan items as data (the editor thin slice’s stream S2): each item’s typed State, the edit that fixes a problem (Op), and one label formatter (items, label), so a caller (the editor, an MCP client) never reads an item’s state from its basis sentence or formats its text again. The basis stays, for a person (ADR R1 invariant 4).
label_text
Author wording around authoritative generated label terms, before ink is measured.
layout
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.
linework
Visible edges take precedence over hidden edges in each placed view (ISO 128-2). Work in page mm, preserving the exact curves when a hidden stretch is split.
lint
Lint: an independent check of a finished drawing against the part.
local_layout
Local fixes retain sheet intent, never page coordinates or item inventories.
material
One material re-entry predicate for the leader router and lint (ADR2-8, ISSUE-798-b/d, draftwright’s material_intervals and material_reentry_span): the page length of a leader shaft inside the part’s material after it has left the material at its tip. A shaft from a feature’s rim out through the body to clear page makes one traversal, the legitimate exit every callout makes; going back in (the body again, or a second body) is the cut, measured as a magnitude, never a flag. dims::leaders prices it and reports it (annotation_line_over_view); lint’s leader_crosses_silhouette reports it on the drawn sheet; both build the material with solids and ask reentry, so they cannot reach opposite verdicts on one shaft.
mcp
Thin local MCP transports over the stateless Session API.
model
The document model (ADR R1, [docs/model.md]):
modelled_threads
ISO 6410 depiction of recognised physical screw threads. The source Part and recognition remain immutable; a drawing-only carrier replaces the claimed flanks.
notes
General notes: the part’s AP242 notes (pmi:<identity>, crate::pmi_lowering::sheet_requirements), then the Spec’s drawing notes (n:<k>), drawn as draftwright draws its document notes (render_document_notes): one GENERAL NOTES table whose rows are document_note_rows’ (each note numbered by its place in the list, 1 BREAK ALL SHARP EDGES, wrapped at 48 characters with continuation rows indented three spaces), in IBM Plex Mono at 3 mm, each row 3 mm plus 2 mm of padding above and below, ruled as _build_table rules it: draftwright’s single-column table, sharing the table’s pieces (src/tables.rs).
output
Drawings in sheet millimetres, y up. SVG/PDF/PNG paint the same layered curves and filled faces; their invisible text remains searchable. DXF uses the same geometry with native text, dimensions, blocks, attributes, hatches and groups. Tagged glyph faces and symbol strokes retain text-run ownership without changing the painted formats.
pack
Assembly drawing packs. Identity is product first, then conservative, proper-rigid geometric equality (see docs/model.md, Drawing packs). Pack intent never edits geometry.
placement_intent
Placement intent relative to views and feature anchors (ADR R1 invariant 1).
plan_cache
An opt-in on-disk memo of finished plans and of the analyses they are made from, so that processes planning the same part under the same Spec (CI’s test shards and acceptance measurements) analyse and plan it once and read it after.
pmi
A part’s AP242 semantic PMI read into draftwright’s PMI records: stage 1 of drawing PMI (draftwright pmi.py, extract_pmi_report). The Analysis carries the report (attach, Reading), each geometric tolerance and datum with where it attaches (Geometry); crate::pmi_lowering lowers it to Plan items. The PMI coverage lint is a later stage.
pmi_lowering
A part’s AP242 PMI lowered to drawing items: stage 2a of drawing PMI. draftwright lowers its PMI records in model/detect.py (build_pmi_features): a complete geometric tolerance becomes a feature control frame (ControlFrame), a complete datum a datum feature symbol (DatumRef), each with the view and strip it is drawn in and the model-space site its leader hangs from (model/declare.py’s gdt_target, and annotations/_gdt.py’s _datum_alternate_view). This module makes the same decisions from the Analysis’s PMI (crate::pmi::Reading); crate::dims::gdt places and draws what it lowers.
png
The drawing as a PNG: the layers Drawing::pdf draws, rasterised at a resolution (draftwright renders its PDF through PDFium at dpi, 150 by default, and refuses dpi <= 0). The pixels need not match PDFium’s; the page is the same size, ceil(page × dpi) pixels each way as PDFium makes it, white, with each layer’s lines and faces in its style (round caps, mitred joins, faces filled non-zero and stroked, as in the PDF). The glyphs are the faces the drawing already holds; the invisible text and the link are not drawn.
process
Per-product manufacturing defaults. No geometry-based process inference.
radius
Radius leader evidence and geometry, independent of the router’s chosen sites.
recognition_corrections
Authored corrections resolved into the ordinary feature inventory. Author intent over recognition, resolved before the one planning/lint waist (R4 ADR1-4). No recognition runs here. Only explicitly named faces are interpreted, conservatively, using the existing Analysis evidence. An empty correction set borrows the Analysis.
remedy_scope
Scope vocabulary shared with independent lint advice; no drawing or authoring state.
revision
Revisions (ADR R3): a drawing’s Spec carried from one revision of a part’s STEP file to the next, and what changed.
section
A section view’s furniture, as draftwright draws it (annotations/sections.py): the cut face hatched at 45° by the even-odd rule, and the cutting-plane line on the view that marks it, a chain line with arrowed wing stubs at its ends pointing the way the section is seen.
sections
Explicit, geometry-referenced longitudinal sections. Unavailable planes warn; they never prevent the remaining drawing from being made.
session
A live drawing over the same Spec edits and recovered planner as the batch API.
shaded
Opaque vector pictorials. Convex coplanar patches are merged within each B-rep face, then a BSP splits crossing polygons and emits them back to front. No raster depth buffer.
sheet_fit
Finished-item footprints for sheet choice; reserved layout bands are never fill.
sheet_policy
Smallest-first automatic paper and sheet-count preferences.
sheets
R5’s allocation: recover paper first, then move cumulative groups of auxiliary content.
spec_gdt
Datums and feature control frames authored in the Spec (draftwright-rust #43 item 1), for a part whose STEP carries no AP242 PMI, or to restate what it carries. Python draftwright’s Sheet.datum(letter, ref) and Sheet.control(ref).<characteristic>(tol, to=…, diameter=…, modifier=…) are the reference for what may be said:
spec_notes
Surface finish, threads, knurls and notes authored in the Spec (draftwright-rust #43 item 1, the second part; stream K1b), the way crate::spec_gdt authors datums and controls. Python draftwright’s Sheet.finish(ra, ref), _Hole.thread(spec, depth=), _Dim.thread(spec), _Dim.knurl(pitch, pattern), Sheet.note(text, ref) and Sheet.default_surface_finish(ra) are the reference for what may be said:
stable_ids
Exact, whole-Spec identity migration. Saved keys without current evidence remain intact.
stateless
Stateless operations over Session, with immutable content and a reusable disk cache.
tables
Corner-block tables: the spec’s tables (t:<k>, set in the spec), drawn as draftwright’s Sheet.table draws a declared table (revision blocks, BOMs, schedules) through Drawing.add_table and _build_table: row 0 the header, each column as wide as its widest cell’s ink with 2 mm of padding each side (at least 2.5 text heights, as _table_metrics), each cell’s ink centred in its cell, IBM Plex Mono at 3 mm, each row 3 mm plus 2 mm of padding above and below, ruled at every column edge and every row edge.
text
Text as draftwright draws and measures its labels — what build123d’s Text gives it through OpenCascade’s Font_BRepTextBuilder: each glyph’s outline from the font file, laid out along its line at the glyph’s advance, lines a line spacing apart, the whole centred on its bounding box (Align.CENTER).
title_block
The title block’s cells: draftwright’s ISO 7200 grid (draftwright_title_block_layout in annotations/_sheet_furniture.py, drawn by build123d_drafting’s TitleBlock) as data, each supplied field placed in its own cell and checked against it.
unexplained
Recognisable shapes among the faces quiddity leaves unexplained (#213): a protrusion, a cut, a chamfer on a hole or shaft edge, a turned step or land, or a periodic tooth pattern. Read from the part’s topology when the Analysis is made; the plan warns of each one the Spec does not state (shape_not_recognised), beside unclaimed_geometry’s count, congruent shapes in one warning.
units
Drawing length units. Geometry and page coordinates always remain millimetres.
wording
How a problem’s message names what it is about, in the words a draftsman reads on the sheet (draftwright-rust #24): a dimension by the text it prints (2× 30), a feature by what is seen of it (the ⌀6.6 hole), a view by its name (the plan view). The IDs stay in the problem’s subjects and refs; its message never carries one (tests/problem_wording.rs scans every message of the test parts for them).