Skip to main content

castiron — compile a CADbuildr foundation DAG into geometry via the IronStream Python binding

Project description

castiron

Compile a CADbuildr foundation design into geometry by casting its DAG into IronStream solids via the ironstream Python binding.

castiron is the end-to-end Python path: foundation (Python) → compile() → IronStream kernel (Rust, via the Python binding) → a file on disk. It is the offline, in-process counterpart to foundation's show() — no broker, no network, no kernel-api.

from cadbuildr.foundation import Part, Sketch, Point, Line, Polygon, Extrusion
from castiron import compile

class Cube(Part):
    def __init__(self, size=20):
        s = Sketch(self.xy())
        p1, p2, p3, p4 = Point(s,0,0), Point(s,size,0), Point(s,size,size), Point(s,0,size)
        poly = Polygon([Line(p1,p2), Line(p2,p3), Line(p3,p4), Line(p4,p1)])
        self.add_operation(Extrusion(poly, size))

manifest = compile(Cube(20), format="stl")
print(manifest.files)   # ['.cadbuildr/build/<dag-hash>/cube.stl']

compile() accepts a foundation Part/Assembly (or an already-serialized DAG dict from foundation.dag_utils.show_dag) and writes stl, step, or json (glTF-like mesh). Output is content-addressed by DAG hash, so a repeated build is a cache hit:

<out_dir>/<dag_hash>/<part_name>.<ext>
<out_dir>/<dag_hash>/manifest.json

How it works

Two pieces (see src/castiron/):

  1. dag.py — the DAG tool: parses foundation's CompilerInputDAG, inverts the numeric type table to type names, and topologically orders the nodes.
  2. nodes.py — the conversion functions: one handler per foundation node type, each emitting IronStream binding calls (make_polygonmake_facemake_prism, make_revol, booleans, …). placement.py maps 2D sketch coordinates into 3D world space.

Adding a node type = writing one handler and registering it in HANDLERS.

Status

Handlers exist for every foundation node type. Against the kernel-truck fixture corpus, 64/70 compile to geometry and 5 more are legitimately sketch-only or empty designs (no solid) — 69/70 accounted for.

Covered: parameters; points/lines/arcs/splines/3D points; closed shapes (polygon, rectangle, square, hexagon, circle, ellipse, custom); sketches / planes / frames (quaternion placement); Extrusion, Hole, Lathe, Sphere; Mirror, Scale, Shell, Stitch; Loft / SurfaceLoft / Sweep / MultiSectionSweep / Helix3D (mesh skinning via ironstream.solid_from_mesh); sheet-metal base + edge flange (other bends forward the flange, matching the Rust reference); Assembly (multi-part, frame-chained placement); and SVGShape (path flattening).

Approximations / gaps, in order of fidelity cost:

  • Fillet / Chamfer / Draft / FullRound forward the solid unchanged — the IronStream kernel exposes no edge-blend op yet (neither does the Rust reference).
  • Sheet-metal bends (Tab/Hem/Miter/Unfold) forward the base flange; no bend deformation.
  • SVGShape flattens <path> data as a single loop (multi-subpath holes and self-intersecting art are approximate); SVG <text> needs a font engine and is unsupported.

Development

Install alongside the sibling repos (ironstream-python, cadbuildr-foundation):

uv pip install -e .
pytest

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

cadbuildr_castiron-0.1.0.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

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

cadbuildr_castiron-0.1.0-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file cadbuildr_castiron-0.1.0.tar.gz.

File metadata

  • Download URL: cadbuildr_castiron-0.1.0.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cadbuildr_castiron-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ec9b4fd188a0d856c105f81dde0acb1ca70419bcb81c33d646d1e4963029bed4
MD5 390da6245bea407553ca539e2dc9d4a9
BLAKE2b-256 28ccf3a2955b7ae805c92085fb31c68a5ee9ed844b5a1ba1ec97edb61285e7d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for cadbuildr_castiron-0.1.0.tar.gz:

Publisher: publish-pypi.yml on cadbuildr/castiron

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

File details

Details for the file cadbuildr_castiron-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cadbuildr_castiron-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7df1f23d8dc0868ac630cfeeabe727b445cbfd29d784e37bae428a85d005573f
MD5 cd385ad380f08af81ca6136e4b763b8e
BLAKE2b-256 2501f39589c24c0cbf8e423913e08d78ec418e72426c8983216005d7a19a31e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cadbuildr_castiron-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on cadbuildr/castiron

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