Skip to main content

Automated technical-drawing generation for build123d

Project description

draftwright

CI PyPI Python License: AGPL v3 Ruff

Automated technical-drawing generation for build123d. Point it at a solid (or a STEP file) and get a fully-annotated multi-view engineering drawing — orthographic views, dimensions, section A–A, ISO hatching, title block — ready to export as SVG and DXF.

from build123d import Box, Cylinder, Pos
from draftwright import make_drawing

part = Box(80, 60, 20) - Pos(0, 0, 5) * Cylinder(8, 20)
make_drawing(part, out="my_part", title="Mounting Block", number="DWG-001")
# writes my_part.svg and my_part.dxf

Or from the command line:

draftwright my_part.step --title "Mounting Block" --number DWG-001
# writes my_part.pdf (the default); add --format to choose:
draftwright my_part.step --format pdf,dxf    # PDF + DXF
draftwright my_part.step --format all        # PDF + SVG + DXF

What it produces

  • Three orthographic views (front, plan, side) sized and scaled automatically to the page
  • Dimensions on every principal envelope face, plus bore callouts (diameter, depth, counterbore, spotface) on all holes, and ø leader-callouts for the external stepped diameters of turned parts
  • Section A–A with ISO 128-44 solid filled cutting-plane arrows and ISO 128-50 45° hatching on the cut face, triggered automatically when blind or stepped holes would otherwise be hidden-line-only
  • Title block (ISO 7200) with part name, drawing number, scale, tolerance, and date
  • LintDrawing.lint() checks annotation coverage, page bounds, and ISO compliance and returns structured LintIssue objects

All output is real build123d geometry, so SVG and DXF export come from the same source and dimensions are live on the DXF layer.

Installation

pip install draftwright

Requires Python ≥ 3.10 and build123d ≥ 0.9.0. Annotation primitives are provided by build123d-drafting-helpers, which is installed automatically as a dependency.

Usage

From a build123d solid

from draftwright import make_drawing, build_drawing, Drawing

# One-shot: write SVG + DXF
make_drawing(part, out="drawing", title="My Part", number="DWG-001")

# Composable: get a Drawing object to inspect or extend
dwg = build_drawing(part, title="My Part")
issues = dwg.lint()          # list[LintIssue]
svg_path, dxf_path = dwg.export("drawing")

From a STEP file

from draftwright import make_drawing
make_drawing(step_file="part.step", out="drawing")

Or via the CLI:

draftwright part.step --out drawing --scale 2 --page A3
draftwright part.step --script   # write an editable .py drawing script instead

Scale and page control

from draftwright import choose_scale

# Auto-select the best ISO/ASME standard scale for an A3 sheet
scale, page_w, page_h, n_steps = choose_scale(80, 60, 20, page="A3")

# Override
make_drawing(part, out="drawing", scale=2.0, page="A2")

Edit, critique, and self-repair

Edit a Drawing in domain vocabulary — the engine places annotations automatically, so you say what to dimension, not where:

dwg = build_drawing(part)

# Inspect detected features and add a dimension in domain terms (auto-placed):
for f in dwg.features("plan"):
    dwg.place_dim(f.page_pos, (f.page_pos[0] + f.diameter, f.page_pos[1]),
                  "below", "plan", dwg.draft, name="dim_pocket")

crit = dwg.lint_summary()   # {"passed", "score", "by_code", "issues":[…suggestion]}
dwg.repair()                # auto-fix mechanically-fixable lint; never worsens

Each LintIssue carries a domain-meaningful code and, when computable, a ready-to-apply suggestion. See docs/adr/ for the design (deterministic generation, the lint→repair loop, and the constraint-based layout engine).

Architecture

draftwright is structured as a part-drawing compiler (ADR 0008): feature detectors → a PartModel IR (Features exposing DimParameters) → a dimensioning planner → renderers, feeding a shared layout/projection/export stack. It builds on two libraries:

draftwright
    └── build123d-drafting-helpers  — Dimension, Leader, HoleCallout, …
    └── build123d                   — CAD kernel

It owns feature recognition (recognition/) and linting (linting/); annotation primitives (Dimension, Leader, etc.) live in build123d-drafting-helpers and can be used independently. The compiler is largely converged in production — turned dims/lengths, centre marks, envelope, slots, holes (callouts/locations/grouping), the section A–A trigger, the prismatic step-ladder + rotational furniture, and PMI/GD&T are all on the IR — the migration is complete (one path; the orchestrator is build → plan → render). See docs/target-architecture.md and docs/adr/. The engine handles view layout (strip/zone model), scale selection, annotation placement, and section rendering.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

draftwright-0.2.0.tar.gz (2.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

draftwright-0.2.0-py3-none-any.whl (320.7 kB view details)

Uploaded Python 3

File details

Details for the file draftwright-0.2.0.tar.gz.

File metadata

  • Download URL: draftwright-0.2.0.tar.gz
  • Upload date:
  • Size: 2.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for draftwright-0.2.0.tar.gz
Algorithm Hash digest
SHA256 92262169b4e59261503efe7d5eac23fea5d0e4a25aa2fe500ccb5b4f543c9e09
MD5 1dbfdd327edcf444f64c03b90c6295c2
BLAKE2b-256 d3e611018b3b0ed2bf92373323de5aac00b1b918c1e0c50b705820c8aaa5ad50

See more details on using hashes here.

Provenance

The following attestation bundles were made for draftwright-0.2.0.tar.gz:

Publisher: publish.yml on pzfreo/draftwright

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file draftwright-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: draftwright-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 320.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for draftwright-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0690889faf9708308457118256be51790eae992828e9392f8cd438a7a2070424
MD5 f0d1fb5b7316f248701693cbb01431bb
BLAKE2b-256 f4be0b46f543e24165d9e5c424e702dd8a7e7a180655a5086650e292c64be423

See more details on using hashes here.

Provenance

The following attestation bundles were made for draftwright-0.2.0-py3-none-any.whl:

Publisher: publish.yml on pzfreo/draftwright

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page