CM3D-007: build123d replaces OpenSCAD as design basis
Context
CM3D-001 chose OpenSCAD with BOSL2 as the design basis. The next parts are a pod enclosure and a station with large rounded, ribbed panels, where exact geometry, real fillets and chamfers and strong tests pay off. A spike ported the pump lid to build123d (0.13, OpenCascade kernel) and compared it with the OpenSCAD lid. The numbers:
-
Parity: the exact volume is 67187.7 mm³. The STL at the export tolerance and the OpenSCAD STL are both 0.011 % below it, and the bounding boxes are equal to 0.001 mm.
-
Tests: 16 pytest tests ran in 3.5 s, against 11.7 s for the four collision variants of the OpenSCAD lid test, which build the whole pump each time. The Python tests count solids, select faces and report overlap volumes. They found a counterbore floor in the middle of a layer and a relief that the OpenSCAD constant had moved by 0.01 mm, both of which the OpenSCAD tests cannot see.
-
Export and picture: STL and 3MF in 4 s, a doc picture with pyvista in 5 s without a display.
-
Footprint: the Python environment is 947 MB (OCP, VTK), against one OpenSCAD installer.
-
Cost of moving the pump: an estimate of 8 to 14 working days to reach today’s state, with no new function for the machine.
-
Weak spots: no 3D hull, fillet errors that do not name the cause, builder-context leaks into helper functions, and API changes in 0.13.
The decision drivers after the spike are one toolchain without a mix of tools, a pump that is rebuilt improved and not 1:1, and a low number of different kinds of purchased parts.
Decision
-
All printed parts are designed in build123d 0.13, pinned in
uv.lock, in the Python packagecm3d. -
The move is complete: the pump is rebuilt in build123d as the second step, improved and not as a copy. The OpenSCAD tree (
common/.scad,pod/,tests/*/*.scad,lib/) and the submodules were removed with it, together with the old runner. -
There is no parity check against the OpenSCAD pump, and no value is copied from the SCAD files without a reason in a comment. The calibrated fits live only in
cm3d.common.fits. -
The pod electronics models follow as the third step, after the pump.
-
The package holds tools and models together as
cm3d.tools,cm3d.common,cm3d.pod.<module>andcm3d.station.<module>. It also holds the bill of materials as Python data (bom.pyper assembly,cm3d bom), which builds on the purchased parts of the models. -
The conventions, tests and tooling are described in CM3D-008: Model code conventions: one package, frozen parameters, algebra style, interfaces, CM3D-009: Verification: geometry tests in pytest, mesh check on every export, fit coupons and CM3D-010: Export, doc pictures and viewer: registries in Python. This ADR supersedes CM3D-001: OpenSCAD and BOSL2 as design basis.
Alternatives considered
-
Keep OpenSCAD and BOSL2 (CM3D-001): No migration cost, but weak tests, no real fillets and a second language next to the tooling.
-
Keep the pump in OpenSCAD and use build123d only for new parts: Avoids the migration now, but means two toolchains, two sets of conventions and parameters in two languages. Rejected, because the move is to be complete without a mix of tools.
-
CadQuery: The same kernel with a similar API, but build123d was chosen for its algebra style and because the spike showed that it works.
-
FreeCAD: GUI-centric, so parametrics and diffs in Git are harder to follow (as in CM3D-001).
Consequences
-
Good: Exact geometry, fillets and chamfers as operations on finished parts, and tests that say what collides, by how much and where.
-
Good: One language for parameters, tests, export, pictures and the bill of materials.
-
Good: No overlap tolerances in the model. Touching faces fuse cleanly.
-
Bad: The environment is about 1 GB, and every Python process pays about 3 s for the import.
-
Bad: Rebuilding the pump costs days, and until it is done the repository carries two toolchains.
-
Bad: The kernel has no 3D hull and gives little help when a fillet fails, so the repo skill lists these pitfalls.