Skip to content

Add the build123d CAD toolchain with validation and quality gates - #1

Merged
gianlazz merged 10 commits into
mainfrom
cad/enclosure-bakeoff
Oct 20, 2026
Merged

gianlazz merged 10 commits into
mainfrom
cad/enclosure-bakeoff

Conversation

@gianlazz

@gianlazz gianlazz commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

What this adds

The code-CAD toolchain for the TEG wedge enclosure, plus the gates that keep it correct.

  • Model source of truth: cad/parameters.py (every dimension) + cad/wedge.py — build123d on the OpenCASCADE kernel. STEP + printable STL are committed under cad/exports/.
  • Artifact validation: scripts/validate_cad.py checks the committed STEP/STL (parse, watertight single-body mesh, sits on the bed, fits the A1 mini 180 mm cube, STEP↔STL agreement, stale-export rebuild). Wired into scripts/validate.sh --cad and CI.
  • Code quality: ruff + mypy on the model, plus 13 pytest geometry tests (envelope, wall thickness, hot-face rebate, four magnet pockets with an intact floor, retention holes, fan bore/mounts, clamp bosses, §8 clamp load, parameter guards). Runs in a dedicated CI job and through pre-commit.
  • Printable artifacts: the CI CAD job uploads wedge_enclosure.{stl,step,png}.
  • Docs: docs/cad-toolchain.md (toolchain contract + VS Code OCP CAD Viewer workflow), docs/validation.md, cad/README.md.
  • JLCPCB fab package (also on this branch): scripts/fab_export.sh, scripts/jlc_bom.py, scripts/jlc_cpl.py, docs/jlcpcb-fabrication.md. Ordering stays manual and approval-gated.

The earlier CadQuery / SolidCraft / FreeCAD bake-off was a comparison exercise; build123d is the tool we are maintaining, so the bake-off sources, exports and runner scripts have been removed from this branch.

Verification

  • scripts/cad-lint.sh — ruff + mypy clean
  • scripts/cad-test.sh — 13 passed
  • scripts/validate.sh --cad — all artifact checks pass
  • CI — CAD artifacts, CAD quality, hardware ERC/DRC, and scripts all green

Reviewer notes

  • Print evidence (A1 mini, PLA Matte, 0.20 mm, Textured PEI) is on LAZ-24.
  • The branch name still reflects the bake-off; the content does not. Rename at merge if preferred.

One command (scripts/fab_export.sh) produces Gerbers + Excellon drill + JLCPCB
BOM + CPL and a gerber zip for upload. scripts/jlc_bom.py reads the schematic's
LCSC Part properties; scripts/jlc_cpl.py converts the KiCad pos file to JLCPCB's
CPL columns. Default is SMT-only assembly with the BOM restricted to the CPL
designators so the two agree; --tht includes through-hole parts.

Ordering stays manual and approval-gated: JLCPCB's official Open Platform API is
application-gated and not wired. Full flow in docs/jlcpcb-fabrication.md.
Agents can now author and edit the printed wedge enclosure as code and export
STEP + printable STL end to end, with no human relaying.

- cad/parameters.py  every dimension (single source of truth)
- cad/wedge.py       parameterised wedge; exports STEP/STL + a 4-view preview
- scripts/cad-setup.sh  sudo-free bootstrap of the repo-local .venv toolchain
- scripts/cad-run.sh    run the model with the right env
- docs/cad-toolchain.md tool decision, layout, conventions, requirements map
- cad/exports/       committed STEP + STL (input to the Bambu print task)

Model satisfies P1 (150x55x150 mm on the 180^3 A1 mini bed), P2 (wedge),
T2/T5 (metal interface plate in a rebate, plastic off the hot path), T4
(SmCo magnet pockets), S2 (M3 retention holes) and the section 8 1.4 MPa
clamp (four M4 bosses, ~2.9 kN). See docs/cad-toolchain.md.
Author the same enclosure (same cad/parameters.py) with two more
agent-drivable tools so the result can be judged by review and print quality,
not by description.

- cad/bakeoff/cadquery/wedge_cq.py   CadQuery port (same OCCT kernel)
- cad/bakeoff/solidcraft/wedge.json  SolidCraft command script (truck kernel)
- cad/bakeoff/*/exports/             committed STEP + STL + preview per tool
- scripts/cad-setup-cadquery.sh, cad-run-cadquery.sh   .venv-cadquery toolchain
- scripts/cad-solidcraft.sh          pins + downloads the SolidCraft CLI
- cad/bakeoff/README.md              comparison, how to run, print guidance
- cad/bakeoff/render_stl.py          kernel-agnostic 4-view preview from STL

All three fit the Bambu A1 mini 180 mm bed and agree on the solid to <0.01%
volume (150x55x150 mm; 248.4 cm^3). build123d keeps its canonical exports at
cad/exports/ for the Bambu print task; the contenders export under cad/bakeoff/.
The user asked to also consider FreeCAD. Author the same wedge enclosure with
FreeCAD's Part scripting API (headless freecadcmd) and add it to the bake-off.

- cad/bakeoff/freecad/wedge_fc.py   FreeCAD port (same OCCT kernel)
- cad/bakeoff/freecad/exports/      committed STEP + STL + preview
- scripts/cad-run-freecad.sh        pins + downloads the FreeCAD AppImage
- cad/bakeoff/freecad/README.md     gotchas (makeThickness, freecadcmd argv,
                                    binary STL via MeshPart)
- cad/bakeoff/README.md, docs/cad-toolchain.md updated for four tools

FreeCAD matches the other three exactly: 150x55x150 mm, 248.4 cm^3 (build123d,
CadQuery and FreeCAD are all OCCT and agree; SolidCraft's truck kernel matches to
rounding). FreeCAD wrote the smallest STEP (54 KB) and coarsest mesh (4,112
facets).
@gianlazz gianlazz changed the title Bake-off: the TEG wedge enclosure in build123d, CadQuery and SolidCraft Bake-off: the TEG wedge enclosure in build123d, CadQuery, SolidCraft and FreeCAD Oct 16, 2026
- scripts/validate_cad.py checks committed STEP/STL artifacts: manifold and
  single-body meshes, bed fit, STEP<->STL agreement, bake-off agreement, and
  a stale-export rebuild of cad/wedge.py.
- scripts/validate.sh is the single entry point (--cad / --hardware) and now
  gates on KiCad error-level violations while reporting warnings.
- .github/workflows/validate.yml runs the CAD, hardware (ERC/DRC + JLCPCB
  package) and script-syntax jobs and uploads the reports.
- docs/validation.md documents what runs, local usage, failure fixes, scope.
@gianlazz gianlazz changed the title Bake-off: the TEG wedge enclosure in build123d, CadQuery, SolidCraft and FreeCAD Add the build123d CAD toolchain with validation and quality gates Oct 20, 2026
@gianlazz
gianlazz merged commit acfe787 into main Oct 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant