/cad-image-to-3d:cad-image-to-3dfrom cad-image-to-3d
Converts 2D orthographic engineering drawings (PNG/JPG) into 3D CAD models as CadQuery code and STEP files, then imports them into Unity projects via CLI. Handles batch conversion, self-refinement loops, and ground-truth scoring.
Ships in cad-image-to-3d. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Reconstructs a 3D solid from a 3-view drawing by writing CadQuery code, checks the code the way an engineer would (render the solid back into a drawing with the same renderer used by the Ortho2CAD benchmark and compare it with the input), and finishes with the parts loaded into a Unity project as a scene.
Paths below:
SKILL_DIR is this skill's base directory, ${CLAUDE_SKILL_DIR}. The reference files
write it as {SKILL_DIR}; substitute the real path, e.g. in subagent prompts.PY is the environment's python: ~/.cache/cad-image-to-3d/env/bin/python, or
$CAD_IMAGE_TO_3D_HOME/env/bin/python if the user set that variable to install elsewhere
(the scripts find the renderer next to that env on their own).WORK is a batch folder you choose with the user (e.g. ./cad-image-to-3d-work):WORK/manifest.json drawings, optional ground truth, agent batches
WORK/cases/<id>/ input.png, unit.json, dims.json, exec0/loop1/loop2/loop3(+_fixN) .py/.step/.png,
final.py, final.step (drawing units), log.md, audit.md
WORK/outputs/ <id>.step (mm), <id>.py, <id>_render.png, summary.md, summary.csv
WORK/unity/ OBJ meshes (Y-up, metres) that step 5 loads into Unity
WORK/unity_urp/, renders/ optional URP preview project and its stills (step 5)
Before starting, ask which Unity project the parts should go into (or whether to create a new one) and what units the drawings use, so the run can end in Unity without another round trip.
bash SKILL_DIR/scripts/setup_env.sh
Creates a conda-forge env (CadQuery, pythonOCC, cairosvg) under
~/.cache/cad-image-to-3d, clones the Ortho2CAD renderer at a pinned commit, and runs a smoke
test. Needs micromamba, mamba or conda (macOS: brew install micromamba) and git; step 5
needs a Unity 6 editor installed via Unity Hub. The renderer is fetched from GitHub rather
than bundled because that repo has no licence file. If setup fails, show the user the error;
don't hand-roll a substitute renderer, because the loop's accuracy depends on comparing
against the exact same drawing style.
PY SKILL_DIR/scripts/prepare_batch.py <images or folders> --work WORK [--per-agent 12] [--gt-dir <STEP folder>] [--unit in] [--source-note "..."]
Pass the unit the user stated with --unit (mm cm m in ft none; stage drawings in different
units with separate calls) and where the drawings came from, with their licence, with
--source-note; both end up in the summary. Copies each image to WORK/cases/<id>/input.png, matches optional ground-truth STEP files by
file stem, and prints agent batches. Re-running only adds new drawings and re-plans the
unfinished ones, so an interrupted batch resumes cleanly. WORK gets its own .gitignore, so
a batch folder inside a git repo (including the user's own) is never committed.
Glance at one or two inputs first. The loop works best on clean line drawings with
front/top/side views; photos and shaded renders work much worse. Figures from handbooks,
manuals or shops (third-angle, a profile view plus an isometric picture, plan plus sections,
dimension tables, missing dimensions) work, but more of the model is inferred: follow
references/protocol.md §2 "Drawings from books, manuals and shops", and tell the user
which cases rely on assumed sizes.
Read references/protocol.md before the first case. It has the step-by-step loop, how to
read the drawings, and common pitfalls (hollow vs solid, curved-dimension labels, when to
stop refining).
references/protocol.md §5. Choose --per-agent so there are at least 2 agents and none
gets more than ~15 cases (e.g. 6 drawings → 2×3, 40 → 4×10, 300 → 20×15). A case takes
~1-3 minutes, so wall time is roughly the largest batch × 2 min. When an agent reports
back, check final.py exists for its cases (prepare_batch.py re-lists anything
unfinished). Wait until every batch agent has finished before collecting; don't end your
turn while they are still running.
Keep the fairness rules in that template whenever ground truth exists on disk: the
modelling agent must only see input.png and its own renders, otherwise the scores are
meaningless.Every case ends with the feature audit (protocol.md §4): count every hole, slot, notch,
tooth and edge treatment the drawing shows (scripts/features.py counts circles and dots as a
cross-check), compare with the final model and fix what is missing in loop3. Small repeated
features such as rivet or nail-hole rows are the usual misses, and the render comparison barely
shows them. Skip the audit only when reproducing the Ortho2CAD paper's numbers.
Why the loop is shaped this way: exec0 is written blind so later stages are true corrections; both refinement loops always run so every case gets the same budget; selection compares renders, not code, because the drawing is the only ground truth the agent has. The audit comes last because it checks completeness (counts), which the visual comparison is weak at.
PY SKILL_DIR/scripts/collect.py --work WORK [--axis-iou]
Writes WORK/outputs/<id>.step, <id>.py, <id>_render.png and summary.md/.csv. Every
STEP in outputs/ is in millimetres: the model is built in drawing units and scaled by the
case's unit (the user's --unit, else the agent's unit.json). The summary records the unit
and its source, and checks each model's bounding box against the overall dimensions the agent
read off the drawing (dims.json, ±2%, --size-tol): verified / mismatch / no_dims. Parts
with a size mismatch or a missing, assumed or conflicting unit are listed under needs
review; never report those as done without saying why. With ground truth it adds the
official Ortho2CAD IoU (exec0 and final) and bounding-box error, computed on the drawing-unit
STEP like the ground truth; --axis-iou adds a slower scale-preserving IoU.
When explaining a low score, say it is your reading: the modelling agent never saw the
ground truth, so its log.md only records visual differences. You may open the GT STEP
yourself at this point (after modelling is finished) to find the real cause.
When reporting scores, mention the metric's blind spots: the official IoU normalizes scale (size errors are invisible, which the bounding-box error covers) and fails on symmetric parts whose principal axes are degenerate (pyramids, nuts score ~0.7-0.8 even when correct).
Read references/unity.md first. Everything runs from the Unity command line (batch mode);
nobody has to open the Editor.
PY SKILL_DIR/scripts/to_mesh.py WORK/outputs --out WORK/unity --unit-scale 0.001
PY SKILL_DIR/scripts/unity_install.py --project <UnityProject> --meshes WORK/unity --name <batch> --build-scene [--create]
to_mesh.py turns each STEP into an OBJ in Unity's frame (Y-up, metres, front view facing
the default camera). The STEP files are already in mm, so keep --unit-scale 0.001 for every
batch, mixed units included; units are settled per case in steps 2-4.unity_install.py copies the meshes and summary.csv to Assets/CadImageTo3D/<batch>/ and,
with --build-scene, saves Assets/CadImageTo3D/<batch>/<batch>.unity with every part on a
labelled grid, at real scale. It writes nothing else in the project and adds no packages.--create with a new folder (e.g. WORK/unity_project) to create a
URP project from the newest installed Unity 6 template first.--build-scene (the
Editor imports the files when it regains focus), then use the menu
Tools > CAD Image to 3D > Build Scene From Selected Folder on the batch folder, or run
that menu item through a Unity editor tool if one is connected to this session.Check the result. The script prints the scene path; confirm the part count matches the
valid STEP count. To see the parts rather than trust the log, render a preview:
unity_showcase.py --work WORK loads them into a separate URP project (WORK/unity_urp,
created on the first run, ~1 min), saves a studio scene and renders WORK/renders/hero_grid.png
plus part_<id>.png, which you can open to check orientation and shape. It normalizes every
part to 25 cm for framing, so say those renders are not to scale.
A short summary: how many drawings, how many produced valid STEP, the stage mix (which stage
the final code came from, including loop3), what the audit added, scores if ground truth
existed (mean/median, ≥0.9 count, the worst cases with your one-line reading of why), the
units and their source, the size-check counts and every part under needs review, the assumed sizes and any drawing contradictions you flagged, and where
things are:
WORK/outputs, the Unity project and scene path (open the project in Unity Hub, then the
scene under Assets/CadImageTo3D/<batch>/), and WORK/renders if you made a preview.
NOTICE (opens in a new tab)assets/unity/CadImageTo3DSceneBuilder.cs (opens in a new tab)assets/unity/ShowcaseRenderer.cs (opens in a new tab)references/protocol.md (opens in a new tab)references/unity.md (opens in a new tab)scripts/cad_iou.py (opens in a new tab)scripts/collect.py (opens in a new tab)scripts/features.py (opens in a new tab)scripts/o2c.py (opens in a new tab)scripts/prepare_batch.py (opens in a new tab)scripts/setup_env.sh (opens in a new tab)scripts/to_mesh.py (opens in a new tab)scripts/unity_cli.py (opens in a new tab)scripts/unity_install.py (opens in a new tab)scripts/unity_showcase.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cad, orthographic-drawing, 3d-reconstruction, cadquery, step, unity-import
npx claudepluginhub skykim/cad-image-to-3d --plugin cad-image-to-3dOther plugins' skills for the same job