Skip to main content

Module model

Module model 

Source
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.
CoincidentBody
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 normal points to is kept and seen from the side removed. The plane is marked on the marked_in view, its ends lettered label.
DimensionSpec
FeatureSpec
What the author decided of a feature.
FilePart
One distinct part of a STEP file, as draftwright parts lists 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.
GeometryLayer
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.
LevelSupport
A horizontal face level’s support: its height and the extents of its faces, mm.
Plan
What the sheet will say.
PlannedSheet
PlannedView
Problem
ProjectionStats
Expensive passes actually performed by a kept cache, including unsuccessful projections.
Projections
RenderedItem
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 along axis, at positions along it (and, for a bounded ramp, other_positions along other_axis), rising from z_lo to z_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.
SheetSpec
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).
ViewGeometry
One view’s projected edges on the page, with the bounds of its visible ink.
ViewSpec

Enums§

AnnotationItem
An annotation that can be rendered independently from every other item and the geometry.
DepthPresentation
Which measured distance defines a cylindrical-mouth pocket’s floor.
DimensionSource
The two sources of dimension intent (ADR4-5).
DimensionSpacing
Sheet-wide dimension-line spacing (SheetSpec::dimension_spacing).
FaceGroup
The group quiddity accounts a face to (face_accounting in its recognition document).
PartChoice
PmiMode
How the part’s semantic PMI participates in a drawing.
SpringDepiction

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 plan reads: 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’s view. A version 1 spec is read through migrate.
SPEC_SCHEMAS
Version 3 anchors feature and ladder IDs on faces. Versions 1 and 2 are read through migrate until crate::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_with reads 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. name is only a display name, never a filesystem path. Browser callers need no filesystem or clock.
analyse_native_bytes_part
analyse_native_bytes of part part of an assembly alone, when given (an index as parts lists them), in its own frame and with its PMI only.
analyse_native_part
analyse_native of 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, as analyse_native.
analyse_native_step_part
analyse_native_step of 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_with reads 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 of parts, 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 in parts, 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 ~1 and a ~ is written ~0, as in a JSON pointer (RFC 6901). add appends its value to the list at its path; a note added without an ID takes the next free n:<k>, a table the next free t:<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: None when 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
plan with 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
plan with draftwright’s bounded layout recovery applied (recover): the plan every caller (the library’s crate::api, so the command line, the JSON-lines service and MCP) is given. A plan that cannot be made is refused as plan refuses 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 in unrecognised the 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; render remains 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 .step and its .step.gz bind identically.

Type Aliases§

LinePose