Repository avatar
Search & Data Extraction
v0.33.0
active

mesh2cad

io.github.emirmrkaljevic/mesh2cad

Mesh (STL/OBJ/PLY) to editable STEP, CadQuery, OpenSCAD or FreeCAD, with a fidelity report

Documentation

mesh2cad

ci PyPI emirmrkaljevic/mesh2cad MCP server

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.

demo

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

Scripts

How it works

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.

Support my open-source work: get a SkinToScan pack
If you find this useful, you can support me by getting a SkinToScan pack, my other project. It's a one-time purchase that directly funds my open-source work.

Buy Single Picture Check, €4.49 Buy 5 Picture Pack, €19.99 (popular) Buy 15 Picture Pack, €54.99