AI has gotten remarkably good at generating images, writing code, and even producing 3D models from text descriptions. But there's a catch: most AI-generated 3D content is designed for games and movies, not factories. Ask a text-to-3D model for a "flanged bearing housing with six M8 bolt holes on a 75 mm bolt circle" and you'll get something that looks like a bearing housing. You can't machine it. You can't 3D-print it to spec. You can't load it into Fusion 360 and change a single dimension.
Real engineering needs parametric, deterministic geometry, where every dimension is exact, every feature is intentional, and running the same design twice produces an identical part down to the micron. That's why manufacturing runs on CAD formats like STEP, not meshes and point clouds.
CADForge is our attempt to bridge that gap. It's a reinforcement learning environment on OpenEnv where agents learn to write real CAD code: CadQuery Python scripts that run on the industry-standard OpenCASCADE kernel. The output isn't a pretty mesh. It's a STEP file that can go straight to a CNC machine.
Why code-based 3D matters
Text- and image-to-3D methods are incredible for creative, artistic content, but they can't produce what engineers need:
- Repeatability. Run the same CadQuery script a million times and get the same part every time. Neural methods are inherently stochastic.
- Manufacturability. A STEP file defines exact mathematical surfaces (B-splines, planes, cylinders). A mesh is an approximation. CNC machines and injection moulds need the real thing.
- Editability. Changing a bolt hole from 8 mm to 10 mm is one number in parametric code. In a mesh, you regenerate everything.
| Text/image-to-3D | Code-based CAD (CADForge) | |
|---|---|---|
| Output format | Triangle mesh (STL/OBJ) | STEP file (exact B-Rep surfaces) |
| Dimensional precision | Approximate, no guaranteed tolerances | Exact: every dimension is a number in code |
| Parametric editing | Regenerate from scratch to change one dimension | Change one number, re-run the script |
| CAD tool interop | Must reverse-engineer into Fusion 360, SolidWorks | Native STEP import into any CAD/CAM tool |
| CNC / injection moulding | Requires mesh-to-CAD conversion (lossy) | Direct: STEP is the industry interchange format |
| Deterministic | Stochastic generation, varies with seed | Same code always produces the same part |
The insight is simple: the things that make code-based CAD hard for humans (verbose, API-heavy, easy to get geometry wrong) make it an ideal training ground for AI. The task is well defined, the output is verifiable, and the reward is dense and deterministic.
How an episode works
1. The agent gets a task. A detailed natural-language description of a mechanical part, every dimension in millimetres:
Create a circular disc flange 100 millimetres in outer diameter and 15 millimetres thick. Drill a central through-hole 25 millimetres in diameter. Then drill 6 bolt holes, each 8 millimetres in diameter, on a bolt circle of 75 millimetres, equally spaced at 60° intervals.
2. The agent has tools. At each step it picks one action:
read_docs: search the CadQuery API docs. It costs a step and earns nothing, so the agent has to learn when looking something up is worth it.execute_cadquery: submit a complete script. It runs in a sandbox and returns detailed geometric properties of the shape.render_object: for vision-language models, a rendered image of the current shape.submit: end the episode. The score is the best reward across all executions.
3. The agent sees what it built. Not an image, but a structured report:
Volume: 16,000 mm³
Bounding box: 80 × 40 × 5 mm
Faces: 6 (all PLANE)
Euler characteristic: 2 (simple solid, no holes)
Shape class: FLAT_SOLID
That's enough to reason: "I was supposed to make a 100 mm disc with seven holes, but I made a flat 80 mm plate with none. My face types should include CYLINDER, and my Euler characteristic should be much lower."
4. The agent iterates. Execute, observe, diagnose, read docs, rewrite, execute again. The episode reward is the best score achieved, so the agent is never punished for trying and failing.

The reward: no vibes, just geometry
Rewards are fully deterministic and computed from pure geometry, which puts CADForge in the same tractability class as code generation and maths, where reinforcement learning with verifiable rewards (RLVR) has shown the most promise. There are three parts:
- Code validity. Did the code run? Is the shape valid, with non-zero volume? If not, the reward is 0.
- Geometric similarity against the ground truth:
- Volumetric IoU (60%): both shapes voxelised on a 64³ grid, trying all six axis orientations and keeping the best.
- Mean Chamfer distance (20%): 2,048 surface samples per shape, nearest-neighbour distances both ways. Catches large missing sections.
- Median Chamfer distance (20%): the same, robust to outliers.
- Object-type signals for common failure modes: volume match (scale errors), sorted bounding-box match, dominant face type (a bracket is all planes, a shaft has cylinders), and Euler characteristic for topology (each through-hole lowers it by 2).
The tasks: from plates to bolt flanges
CADForge ships with 70 tasks across five difficulty levels:
- Simple primitives (1–2). A flat plate, a box with a hole, a cylinder:
box(),circle().extrude(),.hole(). - Multi-feature parts (2–3). L-brackets, plates with corner holes, chamfered blocks, U-channels.
- Complex parts (3–4). Counterbores, bolt-pattern flanges, dovetail grooves, cones and filleted boxes.
- Real-world parts (4–5). 50 tasks from the ThomasTheMaker/cadquery dataset and the ABC Dataset, with complex profiles, multiple cut-outs and up to 20 steps to solve.
# Task 19: bolt-pattern flange
import cadquery as cq
import math
result = (
cq.Workplane("XY")
.circle(50).extrude(15)
.faces(">Z").hole(25)
.faces(">Z")
.pushPoints([(37.5 * math.cos(math.radians(a)), 37.5 * math.sin(math.radians(a)))
for a in range(90, 450, 60)])
.hole(8)
)
Why RLVR works here
Only a handful of domains allow reinforcement learning with verifiable rewards without an LLM judge or learned value model: code generation (run the tests), mathematical reasoning (compare the answer), and 3D mechanical CAD (compare the geometry). Because the reward comes from deterministic geometry, there's no reward hacking against a judge, training runs are reproducible, evaluation takes seconds, and the decomposed reward tells the agent what is wrong, not just how wrong.

What's next
- GRPO and other RL algorithms on the full 70-task suite, across model sizes from 7B to 72B.
- Training vision-language models with image observations.
- Multi-part assemblies where parts must fit together.
- Scaling the task set from the hundreds of thousands of models in the ABC Dataset.
CADForge is open source on GitHub and runs on OpenEnv. New tasks, reward signals, training results or feedback are all welcome.