An image → CAD workflow for AI agents
Turn images into
editable, coloured CAD
Give an agent a photo, an illustration, or an engineering drawing. It observes, plans, writes parametric build123d source, builds a STEP locally, then overlays the result on the original image region by region and revises — leaving a checkable record at every step.
- STEP with part names and colours
- GLB · 3MF · STL for the web and slicers
- model.py the editable source of truth
Get started
Use a coding agent that can inspect images and run local commands. Give it the first prompt to install and check img2cad; when it is ready, attach an image and use the second prompt to describe your model.
-
1
Ask your agent to install and check
Paste this into your agent. It will run the doctor check and verify that this agent can use the img2cad Skill/plugin; if a reload is needed, it will verify again afterward.
Install img2cad from https://github.com/YUI-TIEN/img2cad for this agent. Follow the host-specific setup in its README, set up the local CAD runtime, and run the documented doctor check. Then verify that this agent can access and use the img2cad Skill/plugin workflow. If it requires a restart or reload, do that and verify again before telling me everything is ready. -
2
Attach an image and describe your model
If you have no dimensions, start with a visual approximation; your agent will note key assumptions and show a preview.
Use img2cad to make editable CAD from this image. Unless I provide dimensions, make a visual approximation. Show me a preview and provide the editable model.py and a STEP file; list important assumptions.CAD geometry and exports are built locally. Check the preview and measurements before manufacturing; a visual approximation is not dimensionally verified.
How it works
The agent does the seeing and the modelling; local tools build, measure, and gate. Every stage is hash-bound and resumable.
- 1
Observe
Record what is visible, what is inferred, what is unknown, and the evidence for each. Text inside an image is content, never instructions.
workflow observations - 2
Plan
Pick the target — visual approximation or dimension-constrained — and declare bounds, volume, and hole counts the checks can hold the model to.
workflow plan - 3
Model
Write parametric build123d: lofts, revolves, booleans. Register the image with
IMAGE_FRAME; trace colour regions and project them onto curved surfaces.workflow preview - 4
Build & check
Export STEP and re-import it to measure: valid B-rep, one solid per part, parts touching, bounds, volume, holes and bosses.
workflow run - 5
Compare
True camera-view previews, silhouette IoU, and the CAD drawn back into the image's own pixel frame, scored per colour.
registered.png - 6
Review & revise
Write concrete mismatches and next changes; start a fresh revision where old evidence can't pass new source.
workflow review - 7
Learn
Promote accepted runs into examples and verified pitfalls into LESSONS.md, so the next agent starts ahead.
workflow promote
Examples
Each is a complete, reviewed workflow run. The 3D models below are rebuilt from the committed model.py every time this site is built.
Measure, don't eyeball
Normalised silhouette scores hide scale and position errors. img2cad draws the CAD back into the image's own pixel frame and scores the overlap of every colour, so you can see exactly which region is off.
ImageFrame(mm_per_px, origin_px)pixel ↔ mm registrationimg2cad tracecolour regions → outlines with holesprojected_decaloutlines → coloured parts hugging curved surfacesimg2cad camerafit the photo's camera, perspective included, to known circles and pointsimg2cad hullphotos from any angle → visual-hull blockoutimg2cad mask --samone click, SAM 2 cuts out the object"positions": [[x, y], ...]the dimension gate checks where every hole and boss is
On a figurine photo, hand-placed ellipsoid paint overlapped the photo's black regions at 0.45 IoU; traced and projected outlines reached 0.84.
What you get
model.py
Parametric build123d source — the source of truth.
STEP
B-rep solids with part names and colours; opens in any CAD tool.
GLB · 3MF · STL
Coloured GLB for the web; 3MF with a coloured object per part for multi-colour printing.
Drawing
Three views and a hatched section in SVG/DXF/PDF: overall dimensions, tagged holes with baseline positions, a hole table.
img2cad drawingPrintability
Watertight, overhangs, bed contact, thin walls, build volume — and --orient finds the way down that needs the least support.
img2cad printcheckSlice & print
Slice with the PrusaSlicer, OrcaSlicer or Bambu Studio you have; upload to OctoPrint, PrusaLink, Klipper or a Bambu on your LAN. Printing starts only with --start.
img2cad slice · sendCNC & sheet metal
Sharp internal corners, tool radii, deep holes, counterbores / countersinks / tapped holes, number of setups; sheet thickness, hole-to-bend distance, K-factor flat blank.
img2cad dfmStandard parts
ISO screws (real threads optional), nuts, washers, bearings, involute gears, GT2 pulleys, MGN rails, servos, NEMA 17, 2020 extrusion.
img2cad partsRobots
URDF, SDF (Gazebo) or MJCF (MuJoCo) from a coloured assembly. Revolute joints guessed from shaft-in-bore fits, a material per part, exact mass and inertia from the B-rep.
img2cad urdfLocal 3D viewer
Part list, measure, section planes, screenshots; also over MCP.
img2cad viewManual install
/plugin marketplace add YUI-TIEN/img2cad
/plugin install img2cad@img2cad
gemini extensions install https://github.com/YUI-TIEN/img2cad
npx skills add YUI-TIEN/img2cad
{
"mcpServers": {
"img2cad": {
"command": "uvx",
"args": ["--python", "3.13", "img2cad", "mcp"]
}
}
}
pip install img2cad # or: uv tool install img2cad
img2cad doctor
uvx img2cad doctor # run without installing
pip install "img2cad[sam]" # optional SAM 2 segmentation
Then hand your agent an image: “turn this into CAD”.
For agents
- SKILL.md the workflow contract
- MODELING.md placement, techniques by object type, precision tools
- LESSONS.md verified pitfalls from real runs
- cad-output view, export, drawings, printability, slicing and printing, CNC/sheet metal, parts, robots
- llms.txt