Treating CAD Models as Software


For years, a CAD model was a document I opened in a CAD application.

Now my models live in a Python repository with a Nix environment, tests, exact geometry baselines, parameter perturbation checks, generated STEP files and a browser gallery.

The path there went through Fusion 360, FreeCAD, OpenSCAD, CadQuery and build123d. The important change was not which user interface I preferred. It was deciding that a mechanical design should behave like software.

Fusion 360: useful objects

I started with Fusion 360 and made practical parts.

There was a lid for a cold-brew dripper, a shower shelf, soft vise jaws, a whetstone holder, a ceramic knife handle, measurement blocks, a PVC-pipe separator, a kite-pump cap and a battery holder.

Fusion made it straightforward to turn a measurement and a sketch into a printable solid. It taught me the ordinary loop of personal CAD:

  1. Measure the real object.
  2. Model the missing interface.
  3. Print it.
  4. Discover which measurement did not include clearance.
  5. Change the model and print it again.

The weakness became more visible after I moved my working environment to Linux. In 2024 I was still trying to make Autodesk Identity Manager run through Bottles so that I could launch the program containing my own models.

The application file was editable, but only inside a fairly specific proprietary world.

FreeCAD: owning the document

FreeCAD became the Linux-native alternative. I used it for a concentrated run of models: tools, mounts, a magnetic pen, a bike-pedal tool, beach-trolley parts, clips and the first Kindle page-turning remote.

It was capable enough to make the Kindle enclosure genuinely interesting. I revolved an ellipse-and-circle profile into a laser-pointer-like body, split it into printable shells and subtracted pockets for an ESP8266, buttons and a power bank.

FreeCAD also made me think about document fragility. Its topological naming problem was famous: change an early feature and later operations could discover that “Face3” was no longer the face they had been built against. I followed development builds and the work intended to resolve that class of problem.

I did not stop using FreeCAD because it was useless. I stopped wanting the CAD document to be the only authoritative explanation of how a model was constructed.

OpenSCAD: the model becomes source

OpenSCAD made a different trade. The model was text. Parameters were explicit. Git could show what changed. Generating a family of heat-insert test holes was a loop rather than a row of manually copied features.

I built a kitchen-sink ramp using BOSL2 paths, projections, tangent-circle construction and sweeps. I explored editor integration, Haskell CAD DSLs, ImplicitCAD, SolidPython and libraries dedicated to rounding things.

That last category points at the problem. OpenSCAD’s older geometry model made fillets and some ordinary mechanical finishing unexpectedly difficult. I could express the design as code, but I was spending too much design effort negotiating with constructive solid geometry.

CadQuery and build123d

CadQuery showed what code-first CAD on Open Cascade could look like. It had a useful corpus of examples, electronics models, constraints and reusable mechanical ideas. Its editor and environment were awkward in my Nix setup, but its models remained valuable prior art.

build123d provided the Python interface I preferred while retaining the richer B-rep geometry and interoperability of that ecosystem.

The first obstacle was not modeling. It was assembling a repeatable environment containing compatible versions of build123d, Open Cascade bindings, Yet Another CAD Viewer (YACV) and optional helper libraries. One Gridfinity setup (gridfinity-ezcal) “sort of worked” while build123d, NumPy, build123d_draft and the viewer all wanted different things.

I extracted that work into nix-build123d in July 2025, and in April 2026 rebuilt it on pyproject-nix/uv2nix around build123d 0.10.0. A model could now begin with nix develop rather than an archaeology session in a Python environment.

The models repository

In April 2026 I created a private models repository on top of nix-build123d.

At first it was a Nix flake and one sample model. Within a day it had become a framework:

Then I moved old work into it. Parts which had existed as scattered Fusion, FreeCAD, OpenSCAD or temporary Python projects became build123d modules using one current toolchain.

The repository now contains workshop organizers, household repairs, kitchen parts, mounts, calibration pieces and parameterized families. The individual objects are still small and practical. The difference is that they now share infrastructure.

Static browser gallery generated from the build123d models repository, filtered to the Shop category with interactive 3D previews and GLB/STEP download buttons

Clankers can see the shape

This migration also taught me something unexpected about clankers: they are surprisingly decent at geometry.

An STL is a bad source format. It contains triangles describing the outside surface, not the sketches, dimensions, constraints, fillets or sequence of operations which produced that surface. By the time a model has become an STL, most of its design intent has been erased.

Even so, a clanker can often inspect the mesh and recover a useful constructive explanation. It can recognize repeated radii, symmetry, planar extrusions, cylinders, holes, wall thicknesses and likely boolean operations. It can measure the surviving geometry, propose parameters and rebuild the object as editable build123d code.

That is not the same as recovering the original model. Many feature histories can produce the same boundary, and a triangle mesh does not reveal which dimensions were meant to vary. The result is a reverse-engineered model: a new explanation which reproduces the old shape closely enough to become maintainable.

The clanker is particularly useful in the tedious middle of that process. It can compare extents and sections, adjust inferred primitives, render another candidate and keep narrowing the geometric difference. I can concentrate on the decisions the mesh cannot answer: which dimensions express an interface, which coincidences are accidental and how the model should behave when a parameter changes.

This is another reason the repository infrastructure matters. Clanker-generated reconstruction is a hypothesis. Reference geometry, boolean comparisons, ordinary tests and eventually a physical print are how I check it.

Testing shape

Software tests usually compare values. A CAD regression test needs to compare solids.

The golden check imports a tracked STEP baseline and computes boolean differences in both directions:

current - golden
golden - current

If either difference has a volume above 1e-6, the check fails and tells me the geometry changed. That lets me refactor model code while verifying that I did not accidentally alter the printable result.

Exact golden geometry is not enough for a parameterized model. One set of defaults can work while nearby dimensions make Open Cascade fail, consume enormous memory or produce an invalid solid.

The perturbation harness discovers numeric parameters and dataclass fields, changes them deterministically and builds each case in a resource-bounded subprocess. It accepts explicit validation failures for contradictory dimensions, but catches crashes, invalid geometry and pathological builds.

It is a kind of fuzzing for a mechanical design.

Physical tests still win

The repository does not pretend that passing software checks proves a part will fit.

The G3061 hot-plate screen mount is a good example. Its history includes imported reference geometry, an OLED test mount, dimensions adjusted after a successful print, a low-material fit-test builder, several stand designs and an explicitly abandoned direction.

A fit-test model is often more useful than a perfect render of the entire object. It isolates the uncertain interface, prints quickly and tells me what to change in the next revision.

The software infrastructure makes those experiments reproducible. It does not replace calipers, plastic shrinkage, screw tolerances or trying the part on the real machine.

Reusing intent

Once models were ordinary Python modules, repeated mechanical ideas became visible.

Heat-insert dimensions, countersunk holes, imported assets, clearances and fastener assumptions moved into shared code. The split-keyboard cases put many of those repeated mechanical details into one assembly. A CadQuery print-in-place hinge could be adapted into reusable build123d infrastructure rather than copied as one finished object. An OpenSCAD shopping-cart coin could retain its original profile points while gaining typed parameters and generated variants.

The next experiment goes one level higher. My feature/cad-vocabulary-lab branch describes named interfaces, hard constraints, delegated decisions and executable acceptance checks before binding them to build123d geometry. A Geneva mechanism checks collisions across thirteen poses and exposes its named moving bodies to the gallery animation.

After making the geometry testable, the question became whether some of the design intent could be testable too.

A CAD file is no longer the product

Fusion 360, FreeCAD, OpenSCAD, CadQuery and build123d are not rungs in a universal ranking. Each changed what I expected from the next tool.

Fusion made useful objects accessible. FreeCAD made an open Linux-native workflow plausible. OpenSCAD made source control and parameterization feel natural. CadQuery provided a rich body of Python/OCC examples. build123d gave me the modeling vocabulary I wanted.

The repository completed the change.

The source model, environment, tests, reference assets, gallery metadata and generated artifacts now form one project. STEP and STL files are build outputs. The design history is Git history. Geometry changes can fail the local Nix checks. New parameter ranges can be exercised before they kill an interactive session or waste a print.

I still make the same sort of object I made in Fusion: a clip, a lid, a spacer, a mount, a wedge.

I no longer treat it as a document.