mesh2cad
mesh2cad converts an STL, OBJ, or PLY mesh of a simple mechanical part into editable parametric CAD. It writes a STEP solid you can open in a CAD tool, plus CadQuery, OpenSCAD, and FreeCAD scripts whose dimensions are named parameters. The fit runs on your machine. Nothing is uploaded. It is also an MCP server.
Hackaday covered it, and all 6 Original Prusa i3 MK3S printed parts in the test set convert exactly, as STEP and as a script. See Press and Real parts.
Install
pip install mesh2cad
The mcp extra adds the server, the cadquery extra lets mesh2cad run and check a generated script, and the separate OpenSCAD and FreeCAD programs are covered in Install.
Quick start
mesh2cad convert plate.stl --cadquery plate.py
mesh2cad edit plate.py --set hole_grid_1_d=8 --in-place -o plate.step
The first command writes plate.py with diameters, thicknesses, and positions as names at the top; the second sets the four-hole grid diameter to 8 mm, rewrites the script, and writes plate.step.
Limitations
It is meant for simple mechanical parts: plates, brackets, and boxes with holes, bolt circles, slots, bosses (including on an extruded outline), countersunk and counterbored holes on that outline, and fillets, and a Z extrusion can also carry one radius on every vertical corner of the outline. It fits planes, cylinders, spheres, cones, and constant-radius rounds, and writes those as faces you can select. It does not recover organic or sculpted shapes, scans, or free-form surfaces; when a fit is poor it does not invent a surface, and STEP output falls back to a faceted solid that is still valid, with the report naming that fallback. A script is held to a tighter check (deviation at most max(4 times the tolerance, 0.1 mm), and volume error at most 1%), and the fitted-surface list, the parameter names, and the refusals are in Limits.
MCP
Install the extra with pip install "mesh2cad[mcp]", then run mesh2cad mcp to start the server on stdio.
The tools, client config, and return values are in MCP.
Docs
Getting started
- Install
- CLI reference
- MCP server
Scripts
- CadQuery scripts
- OpenSCAD scripts
- FreeCAD macros
- Editing a parameter
How it works
- How it works
- Limits
- Benchmarks
- Real parts
Project
A mesh that converts badly can go in a GitHub issue. There is a template for an STL that fails.
License
MIT. See LICENSE.