Entry points

Build a drawing

build_drawing(step_file, out=None, title=None, number='DWG-001', tolerance='ISO 2768-m', drawn_by='', scale=None, page=None, auto_dims=True, detail_view=True, pmi=None, repair=True, assembly=None, model=None, decorations=None, requested=None, authored=None, trace=None, material='', date='', revision='A', company='', frame=False, projection=None, zones=False)

Build a customisable 4-view :class:Drawing without exporting it.

Same arguments as :func:make_drawing, but returns the live :class:Drawing so you can add or remove annotations and add section/auxiliary views before calling :meth:Drawing.export. make_drawing(...) is build_drawing(...).export(formats=("svg", "dxf")), unpacked to a tuple.

Parameters:

Name Type Description Default
auto_dims bool

pass False to skip the automatic dimensions, centrelines, and leaders (#74) — the automatic set assumes a turned part and is wrong for prismatic geometry. Views, scale, page, and sheet furniture (title block, and the "ISO VIEW (NTS)" note when the iso is rescaled off sheet scale) are still produced; add your own annotations before export. (Annotations added by the default can also be removed wholesale with :meth:Drawing.clear_annotations.)

True
detail_view bool

automatically recover crowded prismatic step dimensions in an enlarged detail view. Default True; pass False to leave them on the parent view only and report step_dim_dropped when they do not fit.

True
pmi Literal['off', 'report', 'annotate'] | None

AP242 PMI handling. None (the default) behaves as "off" but retains that it was defaulted so a source containing authored PMI can say annotation is disabled by default. Explicit "off" produces no PMI annotations or per-record failures but reports the ignored source inventory; "report" inventories and lowers without rendering; "annotate" also requires render outcomes.

None
repair bool

run the bounded lint→repair loop (:meth:Drawing.repair) after placement to fix mechanically-clear violations (a dim on the wrong side, two overlapping labels). Default True; a no-op on a clean sheet. Pass False to inspect the raw greedy placement (#30).

True
assembly bool | None

severity of the feature-coverage lint for a general-arrangement drawing. None (default) auto-detects — a multi-solid part is an assembly, whose per-part bores are reported at info rather than warning (a GA omits them by design). Force with True/False (#69).

None
model Sequence[Feature] | PartModel | None

a caller-supplied IR (ADR 0011) — a :class:PartModel, or a sequence of :class:Feature\ s (declared with :func:draftwright.model.hole, boss, step, … from the objects you built). When given, feature detection is skipped and the auto-pass dimensions exactly the declared features; None (default) detects normally. Detection and declaration are two producers of the same IR — everything downstream is untouched. (Notes: sheet scale/zone estimation and the coverage lint still detect independently, so a partial declaration will flag the undeclared geometry. A declared hole/pattern now renders at its declared position even where detection missed it (#448); the one remaining detection-dependent bit is the off-axis side-drilled hole location dim, which needs recogniser-Hole geometry a declared feature doesn't carry. See ADR 0011.)

None
trace str | Path | bool | None

the opt-in solve-trace / explain mode (#736): record every strip placement decision as ONE JSON file per build (schema version 2), with two record types. solves — the corridor solves: the candidate set, the obstacles that carved the strip (with owning annotation names), the free segments, and each candidate's outcome (placed/dropped-with- reason/deduped/promoted). pass_events — everything placed outside a corridor solve: the standalone strip passes plus the immediate placers (the post-drain machined-feature leader callouts and the turned diameter/step-length set-solves), each with per-item outcomes. The jq contract — corridor dims vs everything else::

jq '.solves[].outcomes[] | select(.name == "dim_height")' t.trace.json
jq '.pass_events[] | select(.label == "pocket_callouts") | .items[]' t.trace.json

True writes <out>.trace.json beside the drawing; a path writes there (a directory gets <stem>.trace.json inside it). Default None consults the DRAFTWRIGHT_TRACE env var (same path-or-directory semantics); False forces it off. Zero output change: tracing never alters a placement decision, and off (the default) costs nothing. Recording-only: an unwritable trace path logs a warning and never aborts the build/export.

None

Returns:

Name Type Description
A Drawing

class:Drawing with the standard front/plan/side/iso views projected

Drawing

and the automatic dimensions + title block already added.

Build and export in one call

make_drawing(step_file, out=None, title=None, number='DWG-001', tolerance='ISO 2768-m', drawn_by='', scale=None, page=None, auto_dims=True, detail_view=True, pmi=None, assembly=None, material='', date='', revision='A', company='', frame=False, projection=None, zones=False)

Generate a 4-view technical drawing from a STEP file or build123d object.

Parameters:

Name Type Description Default
step_file str | Path | Shape

Path to a STEP/STP file, or a build123d Shape (e.g. a Part, Solid, or Compound) to draw directly.

required
out str | None

Output path stem (default: input filename stem, or "drawing" when a build123d object is passed).

None
title str | None

Part title for the title block (default: stem uppercased).

None
number str

Drawing number (e.g. "DWG-042").

'DWG-001'
tolerance str

General tolerance string (e.g. "ISO 2768-m").

'ISO 2768-m'
drawn_by str

Designer name for the title block.

''
scale float | None

Drawing-scale override (e.g. 5 for 5:1, 0.5 for 1:2). Default: chosen automatically by :func:choose_scale.

None
page str | tuple | None

Page-size override — an ISO name ("A3"), "WIDTHxHEIGHT" in mm, or a (width, height) tuple. Default: chosen automatically by :func:choose_scale.

None
auto_dims bool

pass False to skip the automatic dimensions, centrelines, and leaders (#74) — views, scale, page, and title block only.

True
detail_view bool

automatically add an enlarged view for crowded prismatic step dimensions. Default True; pass False to disable that recovery.

True

Returns:

Type Description
tuple[str, str]

Tuple of (svg_path, dxf_path) for the generated files.

This is a thin wrapper: make_drawing(...) is build_drawing(...).export(formats=("svg", "dxf")), unpacked to a tuple. Not a bare .export() — that is the deprecated legacy shape and warns (#987). To add or remove annotations or add section/auxiliary views before export, call :func:build_drawing and use the returned :class:Drawing.