solidfunc: one code-CAD API on three kernels

This post combines two LinkedIn posts from November and December 2026 and brings them up to date.

I’m halfway through the second run of my course on programming CAx systems. The students build parts with CadQuery’s functional API, which is also the API my book CAD as Code uses throughout. While preparing the course, one question kept coming back: how much of what we teach as “code-CAD” is a property of the idea, and how much is a property of the geometry kernel underneath?

CadQuery and build123d, the best-known open-source code-CAD libraries for Python, are both built on Open CASCADE Technology (OCCT). With only one kernel in view, it’s hard to tell the two apart. So I built a small library to find out: solidfunc.

A typed, functional Python CAD library

solidfunc is a typed, functional Python library for code-based CAD. It started out on SolidCore, a B-rep kernel written in Rust. SolidCore began as a Rust port of SMLib, the NURBS B-rep kernel NVIDIA published as part of USD BRep, and has diverged from it since. The Python bindings use PyO3, so pip install solidfunc is all it takes, with no other Python dependencies.

Here’s a plate with a hole and a rounded rim, exported as STEP:

import solidfunc as sf

plate = sf.box(size_x=80, size_y=50, size_z=10)
hole = sf.cylinder(diameter=20, height=10)
part = plate - hole

top = max(sf.faces(part), key=lambda face: face.centroid[2])
hole_edge = [edge for edge in sf.edges(top) if edge.kind == "circle"]
part = sf.fillet(part, hole_edge, radius=2.0)

sf.export_step(part, "plate.step")

Every operation returns a new value and leaves its inputs unchanged. Selecting faces and edges is plain Python over typed data: a type checker rejects face.kind == "cylindre". In a notebook, a shape at the end of a cell shows up as an interactive 3D view through vtk.js. There’s an example notebook you can open in Colab without installing anything.

Version 0.1 covers single solids: primitives, extrusions, revolutions, lofts and sweeps, booleans, fillets, chamfers and shelling, measurements, and STEP import and export. The parts from the book rebuild with almost the same code. The gallery has a few of them.

Swapping the kernel

One day after the first release, another open-source B-rep kernel in Rust came out: springrep. Its own benchmarks say it’s considerably faster than SolidCore. I wondered whether solidfunc could run on it too, and the port was surprisingly straightforward. Since version 0.1.3, an environment variable picks the kernel:

pip install solidfunc-springrep
SOLIDFUNC_KERNEL=springrep python my_part.py

The obvious next step was OCCT itself. Version 0.1.4 adds it as a third backend through nanocct, new Python bindings for OCCT that Bernhard Walter started this autumn. It installs with pip install 'solidfunc[occt]'. On both springrep and OCCT, 186 of the 190 tests pass unchanged.

I haven’t benchmarked the kernels seriously. In a toy example springrep was indeed much faster, but that’s no basis for a verdict.

What I learned so far

Most of the API doesn’t care about the kernel. The examples build the same solids on all three, with the same volumes and the same faces. Only a smooth loft differs slightly, because each kernel fits it its own way.

The kernel shows through at the edges:

  • How sketches become solids. SolidCore builds solids from geometric sketch records (segments, loops, regions), not from OCCT’s topological edges and wires. That’s why solidfunc’s 2D types are plain curves and profiles, and topology only exists inside a solid.
  • How surfaces are stored. SolidCore stores a round on a straight edge as a cone with a zero half-angle, and revolving produces B-spline surfaces even for a cone or a sphere. Selecting faces by surface type, something CAD code does all the time, therefore depends on the kernel.
  • Mutation. SolidCore’s booleans consume their operands, so a functional API has to copy its inputs to keep every value unchanged.
  • Error messages. Only SolidCore tells you the largest fillet radius that fits.

The README and the backends’ notes list the details.

Exchange between libraries

Before solidfunc, I had proposed __cad_interface__, a draft protocol that would let Python CAD libraries hand shapes and assemblies to each other, much like __geo_interface__ does for geospatial data in Python. A library on a kernel other than OCCT was a good test for it, so solidfunc supports it from the start: it imports parts from CadQuery or build123d (an assembly arrives as a single shape, since solidfunc has no assemblies yet), and tools that support the protocol accept a solidfunc shape. No library supports the protocol natively yet; it’s still a proposal looking for feedback.

An experiment, not a replacement

solidfunc is a small academic experiment and below 1.0, so its API can still change. For real work, use CadQuery or build123d, which solidfunc borrows many ideas from. My course and my book stay with CadQuery.

If you try it, I’d love to hear what breaks and what you’d expect from a code-CAD API that doesn’t depend on its kernel. The best place for that is the issue tracker.