Expand description
The document model (ADR R1, [docs/model.md]):
- Analysis: what the part is;
- Spec: what the author decided, keyed by stable IDs;
- Plan: what the sheet will say, every item with its ID, default flag and basis.
The operations over them are analyse, plan, edit and render: pure, stateless
and deterministic.
This first cut covers the views (which views, the sheet, the scale and the placement) and a title block. Features, dimensions and annotations join the same documents as they are ported.
Re-exports§
pub use crate::output::NTS_CAPTION_ID;
Modules§
- dimension_
geometry - Exact, model-space references for dimensions independent of recognition. Reference keys are versioned fingerprints, never traversal indices or paper positions.
- projected_
ink - The part’s edges and faces as compact evidence for annotation placement.
Structs§
- Analysis
- What the part is: regenerable from its STEP file, never edited.
- Binding
- Which file, and which reading of it, a document was made from.
- Coincident
Body - A placed body of a STEP file that coincides with an earlier one (
coincident_bodies). - Cut
- A section’s cutting plane: the material on the side
normalpoints to is kept and seen from the side removed. The plane is marked on themarked_inview, its ends letteredlabel. - Dimension
Spec - Feature
Spec - What the author decided of a feature.
- File
Part - One distinct part of a STEP file, as
draftwright partslists it (specify-core’s{part, name, faces, instances}, with the product’s id): what a caller chooses a part of an assembly by. The index is the identity; the name and product id are reported beside it. - Geometry
Layer - The geometry layer, in plan view order. Sheet furniture belongs to the annotation layer.
- Invalid
- A request that cannot be met as asked: what was wrong, and what would be accepted.
- Level
Support - A horizontal face level’s support: its height and the extents of its faces, mm.
- Plan
- What the sheet will say.
- Planned
Sheet - Planned
View - Problem
- Projection
Stats - Expensive passes actually performed by a kept cache, including unsuccessful projections.
- Projections
- Rendered
Item - One item’s ink and provenance. Run indices are local until appended to a drawing.
- Riser
- A step riser as quiddity records it (
RiserEvidence): a wall (vertical) or ramp facing alongaxis, atpositionsalong it (and, for a bounded ramp,other_positionsalongother_axis), rising fromz_lotoz_hi; whether each end lies on the part’s top or bottom; the tolerance it was read with; and the heights of its solid’s levels. - Sheet
Spec - Spec
- What the author decided. Anything absent takes its default.
- Squared
- How a part slightly off the file’s axes was set square to them (
Analysis::squared). - Unanalysed
- Why a STEP file gave no Analysis. It reads as its message.
- Unrecognised
- A family of features the recogniser did not give the Analysis (quiddity’s family name).
- View
Geometry - One view’s projected edges on the page, with the bounds of its visible ink.
- View
Spec
Enums§
- Annotation
Item - An annotation that can be rendered independently from every other item and the geometry.
- Depth
Presentation - Which measured distance defines a cylindrical-mouth pocket’s floor.
- Dimension
Source - The two sources of dimension intent (ADR4-5).
- Dimension
Spacing - Sheet-wide dimension-line spacing (
SheetSpec::dimension_spacing). - Face
Group - The group quiddity accounts a face to (
face_accountingin its recognition document). - Part
Choice - PmiMode
- How the part’s semantic PMI participates in a drawing.
- Spring
Depiction
Constants§
- ANALYSIS_
SCHEMA - Version 2 added the isometric box (
iso_bounds) and the recognised features, version 3 the horizontal face levels (levels), version 4 their supports and the step risers (level_supports,risers), version 5 the families the recogniser did not give (unrecognised), version 6 the principal boundary faces’ loops lint’s profile check reads (principal_profiles), version 7 the part’s AP242 PMI (pmi), and version 8 the supporting faces of ladder evidence and optional legacy feature identities. - ANALYSIS_
SCHEMAS - The analyses
planreads: this version, and versions 2 to 7 (it reads them with none of what they lack). - MAX_
STEP_ BYTES - Most decompressed STEP text accepted from a gzip file: gzip expands by up to about 1000:1, so a few KB can otherwise claim gigabytes. A WASM page has 4 GB in all, so it takes less.
- NOT_
IN_ NATIVE_ DOCUMENT - Families absent from the native document. Recognition/3 carries all families this consumer requires; unsupported published families are reported per part instead.
- NTS_
CAPTION - The caption draftwright prints under an isometric drawn off the sheet’s scale, and the name
of the drawn item (draftwright’s
note_iso_nts). - PLAN_
SCHEMA - PROJECTIONS
- The Spec’s projection methods (
sheet/projection), ISO 5456-2’s first and third angle. - SECTION
- Section A-A’s view name (draftwright’s
section_aa). - SPEC_
SCHEMA - Version 2 names a dimension by what it measures,
d:<feature>/<parameter>(version 1 added the view that carries it,@<view>), and a PMI item by its record’s semantic identity (version 1 by its Part 21 instance,pmi:<category>:#<n>); the carrying view is the entry’sview. A version 1 spec is read throughmigrate. - SPEC_
SCHEMAS - Version 3 anchors feature and ladder IDs on faces. Versions 1 and 2 are read through
migrateuntilcrate::stable_ids::LAST_LEGACY_SPEC_READER. - SQUARE_
WITHIN - A part’s own frame (quiddity’s
infer_part_frame) within this many degrees of the file’s axes is taken as the axes it was meant to lie on (#216): a library or exported model a fraction of a degree off them is drawn square, not as a tilted box.
Functions§
- analyse
- Reads the STEP file at path: the part, and its analysis, without features.
- analyse_
native - Reads the STEP file at path, as
analyse_withreads it, with its features from Rust quiddity’s recognition document (crate::bridge::native) in place of Python quiddity’s JSON. Refused, as the kernel’s failure, when the native reader refuses the document; never read as a part without features. - analyse_
native_ bytes - Analyse in-memory STEP (or gzip) bytes with Rust feature recognition.
nameis only a display name, never a filesystem path. Browser callers need no filesystem or clock. - analyse_
native_ bytes_ part analyse_native_bytesof part part of an assembly alone, when given (an index aspartslists them), in its own frame and with its PMI only.- analyse_
native_ part analyse_nativeof one part of the file when part is given (analyse_step_part).- analyse_
native_ step analyse_step, with its features from Rust quiddity’s recognition, asanalyse_native.- analyse_
native_ step_ part analyse_native_stepof one part of the file when part is given (analyse_step_part).- analyse_
step - Reads bytes, the STEP file named path (which is not read: the name is for the part and
for messages), as
analyse_withreads a file, without features: for callers that have the file’s bytes and no file system, such as a browser. - analyse_
step_ part analyse_step, of one part of the file when part is given: part k ofparts, read alone in its own frame (haecceity::StepFile::part, its first placement’s shape with no placement applied), its PMI only (other parts’ records are dropped). The binding names the part and its index. Part 0 of a file of one part is the whole file, read as with none. With none, an assembly’s parts are listed inparts, and its principal part, if any, is read alone ([principal_part]; the plan warns that the others are not drawn), or the one part every body coincides with; otherwise the file is read whole. Refused, naming the parts, when there is no part k.- analyse_
with - Reads the STEP file at path, with its features from recognition: Python quiddity’s JSON
for the same file, written by
tools/recognise.py(crate::bridge). Refused when the kernel did not resolve a face or edge the isometric draws. - analyse_
with_ part analyse_with, reading one part of an assembly alone when part is given (analyse_step_part).- as_
analysed - part, read from the file analysis was made from, as analysis drew it: set square to
the file’s axes when it was (
Analysis::squared). - edit
- Applies edit operations to a spec. Each operation is
{"op": "set" | "remove" | "add", "path": "a/b/c", "value": …}, with paths into the spec’s JSON; a/inside a key (a dimension’s ID) is written~1and a~is written~0, as in a JSON pointer (RFC 6901).addappends its value to the list at its path; a note added without an ID takes the next freen:<k>, a table the next freet:<k>. The result is validated whole, so an unknown field or a value of the wrong kind is refused with the reason. - embedded_
spec - The spec embedded in a rendered SVG, DXF or PDF, so a drawing can be resumed from the file
alone:
Nonewhen the drawing carries none. The format is told by the file’s signature; a file that is none of the three, or a spec that does not read, is an error saying why. - migrate
- spec as this version reads it (
draftwright.spec/3), with the exact face-ID map applied throughout its keys and string references. A version 1 spec additionally has each dimension’s key rewritten to the form it now has (R1 invariant 9: a change of form is read, never guessed at): - nts_
caption_ at - Where the NTS caption of size is centred, for an isometric whose drawn box is iso and
whose projection centre is at x = centre_x (draftwright’s
place_iso_nts_note): two font heights below the iso; failing that, further below; beside it, left then right; and only last above it. The first whose box, with the text padding round it, clears every obstacle and stays inside the drawable area wins. Retry without extra text clearance, then slide candidates vertically clear of obstacle edges before retaining required content at the natural position; structural lint reports any unavoidable clash. - part_
list 0: plate, 1: pin: an assembly’s parts as a message names them.- parts
- The distinct parts of the STEP file bytes (named path, for messages), in haecceity’s
order: what
analyse_step_part’s part indexes. - plan
- Plans the sheet: which views, where, at what scale and on what sheet, as draftwright’s layout
does (
layout): each principal view is a block of its box and the annotation bands reserved around it, packed third-angle; the isometric takes the largest space left. Each choice the spec leaves open is marked as a default, with the reason for it. - plan_
escalated planwith draftwright’s drop and escalate applied (crate::hole_table): a hole callout or location placed off the sheet is dropped and reported, and may escalate to a plan-view hole table with balloons. What the recovery judges, as draftwright’s escalation runs inside every build its recovery compares.- plan_
incremental - Place edited annotation content around the committed drawing’s retained ink and views. This never invokes sheet recovery. Unsupported layout changes are refused explicitly.
- plan_
incremental_ source - Incremental planning across a STEP PMI revision. Compare canonical exact B-reps, including topology, trims and units, rather than sampled envelopes or STEP byte hashes. Source face traversal must remain identical; a changed B-rep requires the full path.
- plan_
recovered planwith draftwright’s bounded layout recovery applied (recover): the plan every caller (the library’scrate::api, so the command line, the JSON-lines service and MCP) is given. A plan that cannot be made is refused asplanrefuses it.- read_
step_ file - The STEP text of the file at path (
step_bytes: gzip is decompressed). - recognise
- Takes analysis’s features from Python quiddity’s recognition JSON for the same file
(
crate::bridge). - recognise_
document - Takes analysis’s features from doc, Rust quiddity’s recognition document for part
(
crate::bridge::native), in the part’s own frame, and records inunrecognisedthe families doc has that are not read, and those it does not carry (NOT_IN_NATIVE_DOCUMENT). A refused document leaves analysis as it was. - recognise_
native - Takes analysis’s features from Rust quiddity’s recognition of part
(
recognise_document). - recover
- Select from finished, complete drawings under the maintainer’s sheet policy (2026-10-12). Find the smallest fit and its largest scale; only its immediate larger sheet, with an enlargement, may compete. Pins keep their canonical sheet; explicit choices override.
- render
- Draws the plan: each view projected with hidden lines, placed and scaled, and the title block. The spec travels in the output. Refused when a drawn face or edge of part did not resolve on reading.
- render_
annotations - Assembles a geometry layer with the plan’s annotations and sheet furniture. Each dimension
and PMI item uses
render_item, so a caller can draw a changed item alone. - render_
annotations_ with_ items - Assembles the same drawing, reusing independently rendered annotations by ID.
- render_
geometry - Draws only the views’ edges, reusing projections, placed curves and visible bounds.
- render_
item - Draws a dimension, callout, feature control frame, datum symbol or PMI label from the plan.
- render_
sheets - Draw every planned sheet in order, each carrying the whole Spec. Projections are shared
across the document;
renderremains the sheet-1 entry point. - render_
with render, projecting each view through projections: one kept across a part’s renders draws the same drawing without projecting a view again.- step_
bytes - The STEP text of bytes: decompressed in memory when they are gzip (they begin with its
magic bytes
1f 8b, whatever the file is called), else as given. Every hash or binding of a STEP file is of these bytes, so a.stepand its.step.gzbind identically.