Skip to main content

Module pmi

Module pmi 

Source
Expand description

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.

draftwright reads PMI through OpenCascade’s XCAF document, with Part 21 overlays where XCAF loses something (magnitudes, datum supports, dimension groups). The port reads it through haecceity’s semantic reader (haecceity::pmi::read), which walks the Part 21 instances from each part and reports every instance it did not read as a finding. The report keeps draftwright’s shape:

  • Record is PmiRecord, for the categories the port projects: dimension (with common labels), geometric_tolerance, datum, manufacturing_requirement and surface_label (below). kind, type_code (XCAF’s type number for the same kind), value (mm, or degrees for an angle), the deviations, the limits, label (as _pmi_schema._make_label and pmi._geometric_tolerance_record write it), datum_refs, gtol_modifiers (draftwright’s names), basic and part21_id keep draftwright’s meaning, with two differences of convention: a deviation is signed (lower_tol -0.2, not draftwright’s unsigned 0.2, so a g6 shaft’s two negative deviations survive), and an unstated nominal is None, not 0. One datum record per datum, as _coalesce_datum_records projects XCAF’s occurrences onto their datum feature. A record’s blockers are its lowering_blockers: what the record does not carry (a dimension’s qualifier, a tolerance’s projected zone, a datum’s targets, …) and every haecceity finding on an instance the record was read from.

  • Manufacturing requirements, surface labels and common labels are read from Part 21 alone, as draftwright reads them (_pmi_part21.py), from what haecceity reads of them: a requirement in words (haecceity’s note) is a record labelled with its text and kinded by its name, taking the faces and fields of its structured statement (a ‘pmi-assist’ attribute set, or the part’s general tolerance class) where the pairing is unambiguous on the part (PartReader::requirements); a structured statement left unpaired is a record of its own; text on a shape aspect is a surface label (a ‘NOTE’ aspect) or a common label (XCAF’s CommonLabel, a dimension of kind common_label) (PartReader::labels). Their value is None (draftwright’s placeholder 0). AP242 surface textures (ISO 1302), which draftwright does not read, are records too (PartReader::semantic_textures): the part’s own a default surface_texture, one on faces a surface_finish. Part-level semantic text attribute sets are manufacturing requirements too (PartReader::part_notes): general notes, surface treatments, heat treatments and edge conditions, with text and optional one-based note index (or legacy order/index) fields; they need no presentation.

  • The faces a record applies to replace draftwright’s XCAF shapes: faces, the drawing’s face indices (haecceity’s, the file’s own order, as crate::bridge uses), face_ids their ADVANCED_FACE instances, and face_groups, a location’s two sides or a size’s one (draftwright’s reference_item_groups). ref_bbox (their box) and dominant_axis are in the frame the drawing uses, the file’s own: the port draws a part where the file puts it, which is draftwright’s frame-less extraction (frame=None). A geometric tolerance’s and a datum’s geometry (draftwright’s ref_pts, reference_axis, reference_surface_kind and reference_normal) is derived from the faces for lowering, and so is a dimension’s (its proven stations, or its cylinders: crate::pmi_lowering::dimension_geometry).

  • Source is PmiSourceEntity: what was not read, and why, as a not_extracted source; every read record is a source too (extracted, or partially_extracted with its blockers). Recognised Draftwright bookkeeping is an extracted source of category other, with no drawing record or requirement. Not read: every haecceity finding not on a record’s instances; every item haecceity reads that the port does not project (attribute sets that are no part note, label or structured requirement, general tolerance tables, AP242 thread and turned_knurl features the port does not read as records, material, standards, datum targets, tolerance relations); and every record whose face or edge does not resolve to the drawing’s part, which is never guessed. Presentation is counted (Accounting); decoded callout names and semantic links are retained for triage by crate::graphical_pmi. Graphical strokes are not interpreted as requirements.

  • Material is draftwright’s MaterialFact: each part’s stated material, for the coverage lint’s title-block check; it stays a source not projected too, as no record holds it.

The census is per Part 21 instance, not per XCAF label, so its sources do not pair one for one with draftwright’s; records are compared one for one (tests/pmi.rs). Output order is the category (dimensions, tolerances, datums, requirements, surface labels), then the part, then the reader’s order.

Modules§

graphical
Decoded graphical source evidence, independent of planning and authoring policy.

Structs§

Accounting
How the file’s semantic-PMI instances were accounted for (haecceity’s accounting).
DerivedTarget
An infinite target resolved by the kernel from a derived shape aspect’s faces. Coordinates and support faces are in the drawing’s placed frame; supplemental items remain cross-check evidence in the kernel and never select the drawing target.
FaceAttachment
One face’s attachment, as [datum_geometry] and [tolerance_geometry] measure it from the part: what a record on the face needs of it to lower. The Analysis carries one per face (face_attachments), so a datum or tolerance authored in the Spec, planned with no part to hand, attaches exactly as an AP242 record on the same faces does (crate::spec_gdt).
Geometry
Identities
The drawing item IDs of a part’s PMI records: each record’s semantic identity, never its Part 21 instance, so a file whose intent is written again (new instance numbers, the same requirements on the same faces) keeps every item’s ID (Report::identities).
Material
A part’s material as the file states it (CAx-IF’s ‘material name’ property: draftwright’s MaterialFact, read by haecceity).
Reader
A single part’s latest PMI reading. Material, manufacturing requirements (including threads) and frames all consume this one report. Keeping the reader across edits also retains empty and refused readings; changed bytes replace the reading rather than accumulate documents.
ReaderEvidence
Record
One semantic PMI requirement of a part (draftwright’s PmiRecord).
Report
A part’s PMI as draftwright reads it (PmiExtractionReport).
Source
One source and the outcome of reading it.

Enums§

Category
draftwright’s source categories (PmiSourceCategory), and other for what haecceity reads or reports that belongs to none of them (shape aspects, properties, standards).
DerivedKind
Field
A structured requirement’s field value, as draftwright holds it: text, or a length in mm.
GeometryRefusal
Where a geometric tolerance or datum attaches to the part, in the drawing’s frame (the file’s), as draftwright measures it from the record’s faces (_datum_geometry_from_shapes, _datum_reference_normal and _common_principal_cylinder_axis), and where a dimension does.
Outcome
draftwright’s extraction outcomes (PmiExtractionOutcome), less presentation_only: graphic presentation does not become a semantic record (ReaderEvidence::callouts).
Reading
A part’s PMI as the Analysis carries it: the report, or why the file’s PMI could not be read at all.

Constants§

PMI_SCHEMA

Functions§

attach
What the Analysis carries of the STEP file bytes’ PMI, read on the drawing’s part: the report when the file has any PMI to account for (a record, a source, or a counted instance), none when it has none. A file that cannot be read is refused with the reason when its text names a semantic PMI entity, so PMI the reader loses is said, never dropped.
face_attachments
Every face’s attachment, for the Analysis: a face whose box, sites or normal are not finite keeps only what is (JSON has no infinity), and a record on it is not lowered.
fmt
A nominal with at most three decimal places; or exactly decimals places (no negative zero).
fmt_g3
%.3g, as draftwright labels a tolerance (f"{value:.3g}").
fmt_magnitude
draftwright’s _fmt_pmi_magnitude: at most 13 significant digits without trailing zeros, or exactly decimals places of the value’s shortest decimal form, rounded half to even.
identity
A record’s semantic identity (the editor’s gdt::editor_key, upstreamed): its category and kind (.basic for a basic dimension), its part in a file of several, the drawing faces and edges it applies to, its datum references and modifiers, and, for a datum or a label, its letter or text. Each field after the first is tagged (p, f, e, ref=, mod=, t=) and left out when empty: geometric_tolerance.position:f12,13:ref=A,B:mod=maximum_material_requirement. No Part 21 instance enters it, and neither does a value: a rewrite of the same intent keeps it, and a changed magnitude is the same item with another label.
read
Reads the semantic PMI of the STEP file bytes, whose part the drawing read as part (haecceity::read_step of the same bytes). Refused when the file’s parts cannot be read or do not match part’s faces; everything within a part that cannot be read is a source with a reason.
read_part
read, where the drawing’s part is part chosen of the file’s parts read alone (haecceity::StepFile::part), when given (report_part).
report
The report of a haecceity reading read of doc (whose parts are defs), on the drawing’s part.
report_part
report, where the drawing’s part is part chosen of defs read alone, when given: only that part’s records, findings and material are reported, and the other parts’ are dropped (they are not on this drawing). Its records keep their part’s index in defs.