Skip to main content

Module api

Module api 

Source
Expand description

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.

An Error is invalid (the request cannot be met as asked; it says what would be accepted) or failed (something went wrong; each file is published only when complete).

Re-exports§

pub use crate::png::DPI;

Structs§

Error
Why an operation did not complete.
Review
A drawing to look at: the plan rendered as SVG, with its problems and lint’s findings on the drawing.
Service

Enums§

Features
Where an analysis takes the part’s features from.

Constants§

DEFAULT_FORMATS
The formats written when none are named: the drawing’s vector files.
FORMATS
The formats render writes, including editable DXF drawings.
MONO
The drawing’s font (IBM Plex Mono), bundled.
OPERATIONS
The operations call answers, in the order they are usually used.
SESSION_OPERATIONS
Additional operations on the connection’s one live part; batch operations still work.
STATELESS_OPERATIONS
Stateless subprocess operations; tool calls use the same published MCP schemas.

Functions§

analyse
The Analysis of the STEP file at step, with the features in features, Python quiddity’s recognition JSON for the same file (crate::bridge), when given.
analyse_from
The Analysis of the STEP file at step, with its features from features.
analyse_part
analyse_from of part part of an assembly alone, when given.
call
Operation op with JSON arguments args, its result as JSON:
edit
spec with the edit operations ops applied.
parts
The distinct parts of the STEP file at step, in the order a part is chosen by (model::analyse_step_part): each one’s index, name, product id, face count and number of placements.
plan
The Plan for the STEP file at step (with features, as for analyse) under spec.
plan_analysed
The Plan for analysis (made by analyse) under spec. No STEP file is read; a document of a version model::plan does not read is refused. Every plan here has draftwright’s layout recovery applied (model::plan_recovered).
plan_from
The Plan for the STEP file at step, with its features from features, under spec.
plan_part
plan_from of part part of an assembly alone, when given.
render
The plan (its problems with the drawing’s), and the drawing in each of formats (from FORMATS) as bytes, each carrying the spec; a PNG at DPI.
render_analysed
render_at from analysis (made by analyse from the STEP file at step) in place of analysing it again: refused when analysis is of another version, or was made from another file (its binding’s SHA-256 or face count differs).
render_at
render, with a PNG at dpi pixels per inch: refused, as draftwright refuses it, when a PNG is asked for and dpi is not positive.
render_from
render_at, with the part’s features from features.
render_part
render_from of part part of an assembly alone, when given.
review
The drawing of the STEP file at step under spec, as SVG text, with its problems and lint’s findings.
review_analysed
review from analysis in place of analysing the STEP file again, refused as render_analysed refuses it.
review_from
review, with the part’s features from features.
review_part
review_from of part part of an assembly alone, when given.
spec
The spec embedded in the drawing (SVG, DXF, PDF or PNG) at drawing.
spec_ops
The set and remove ops on escaped paths (crate::items::key) that turn Spec before into after, as crate::items::Ops for crate::session::Session::apply: object keys in sorted order, schema at the root skipped, arrays and scalars replaced whole, an object new in after set key by key (an empty one set whole, {}), and a key missing in after removed. An explicit null in after also removes the key, as the MCP’s spec_diff does; the editor’s specOperations sets null there instead. A serialised Spec never holds null, so for Specs the three agree.
write
Writes each rendered file at out with its format’s extension appended (part.rev2 → part.rev2.svg; an out already ending in a drawing format’s extension has it replaced, as draftwright’s _output_prefix does), and returns the paths written. Each is written to a uniquely and exclusively created sibling, then atomically replaces its destination. A failed write/rename does not replace that destination and removes only this invocation’s staged copy (ADR5-10). Concurrent writers use last-writer-wins per file (the last successful rename). A multi-format export is not transactional: formats may come from different writers, and a later failure leaves already published formats in place.

Type Aliases§

Files
Rendered files: each suffix (svg, sheet2.svg, pdf, etc.) and its bytes.