Official code repository of "CADFit: Precise Mesh-to-CAD Program Generation with Hybrid Optimization" @ ICML 2026
52
stars
11
commits
Python
primary language
Jun 17, 2026
updated
Ghadi Nehme1, Eamon Whalen2, Faez Ahmed1
1Massachusetts Institute of Technology
2Siemens Digital Industries Software
CADFit is a hybrid optimization-based framework that recovers complex, editable CAD construction sequences from watertight meshes by incrementally fitting and validating parametric operations using geometric feedback. Rather than predicting programs in a single forward pass, CADFit formulates reconstruction as an explicit IoU-driven optimization over executable CAD programs, supporting a rich operator set (extrusions, revolutions, fillets, chamfers) composed using Boolean union and cut.
Extrude, Revolve, Fillet, Chamfer, Union, Cut — far beyond sketch-and-extrude pipelines.Union / Cut, until residual volume falls below tolerance.
DeepCAD, Fusion360, and ABC (easy/medium/hard). CADFit produces a valid, editable CAD program on every input where baselines either output Invalid or visibly diverge from the target geometry.
CADFit is agnostic to where the mesh comes from. Pairing it with a pretrained image-to-3D model — we use Hunyuan3D — and standard post-processing (watertight enforcement, Taubin smoothing, mesh decimation) gives a fully end-to-end image-to-CAD pipeline.
Every CADFit run emits an executable Python script that reproduces the solid in CadQuery:
conda create -n cadfit-env python=3.10 && conda activate cadfit-env
pip install -r requirements.txt
Reconstruct every STL in a folder:
python run_pipeline.py <input_folder>
Outputs land in <input>_runs/<stl_id>/ (override with --output-folder OUT):
<input>_runs/<stl_id>/
├── best_greedy_parallel_iterative.stl # final reconstruction
├── best_greedy_parallel_iterative.py # equivalent CadQuery program
└── final_iou.json # { final_iou, duration, ... }
Common flags:
| flag | effect |
|---|---|
--max-iterations N | residual cut/union refinement passes (default 1) |
--skip-existing | resume — skip STLs whose final_iou.json exists |
--fillet-chamfer | enable per-edge fillet/chamfer pass (off by default) |
--limit N, --start-from FILE.stl | narrow the input list |
For best throughput on a multi-core box, raise the inner worker pool:
CADFIT_INNER_WORKERS=25 python run_pipeline.py abc_hard
Call from Python directly:
from run_pipeline import process_single_stl
process_single_stl("abc_hard/00013080.stl",
folder_name="abc_hard_runs",
max_iterations=1)
If you find our work helpful, please consider citing:
@article{nehme2026cadfit,
title={CADFit: Precise Mesh-to-CAD Program Generation with Hybrid Optimization},
author={Nehme, Ghadi and Whalen, Eamon and Ahmed, Faez},
journal={arXiv preprint arXiv:2605.01171},
year={2026}
}
Released under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license — free for academic and research use; see LICENSE for full terms.
A provisional patent application has been filed covering the CADFit method. Commercial licensing inquiries: ghadi@mit.edu.
For questions, issues, or collaboration, please contact: ghadi@mit.edu
11 commits
Python
95.3%
C++
4.0%
Official code repository of "CADFit: Precise Mesh-to-CAD Program Generation with Hybrid Optimization" @ ICML 2026
52
stars
11
commits
Python
primary language
Jun 17, 2026
updated
Ghadi Nehme1, Eamon Whalen2, Faez Ahmed1
1Massachusetts Institute of Technology
2Siemens Digital Industries Software
CADFit is a hybrid optimization-based framework that recovers complex, editable CAD construction sequences from watertight meshes by incrementally fitting and validating parametric operations using geometric feedback. Rather than predicting programs in a single forward pass, CADFit formulates reconstruction as an explicit IoU-driven optimization over executable CAD programs, supporting a rich operator set (extrusions, revolutions, fillets, chamfers) composed using Boolean union and cut.
Extrude, Revolve, Fillet, Chamfer, Union, Cut — far beyond sketch-and-extrude pipelines.Union / Cut, until residual volume falls below tolerance.
DeepCAD, Fusion360, and ABC (easy/medium/hard). CADFit produces a valid, editable CAD program on every input where baselines either output Invalid or visibly diverge from the target geometry.
CADFit is agnostic to where the mesh comes from. Pairing it with a pretrained image-to-3D model — we use Hunyuan3D — and standard post-processing (watertight enforcement, Taubin smoothing, mesh decimation) gives a fully end-to-end image-to-CAD pipeline.
Every CADFit run emits an executable Python script that reproduces the solid in CadQuery:
conda create -n cadfit-env python=3.10 && conda activate cadfit-env
pip install -r requirements.txt
Reconstruct every STL in a folder:
python run_pipeline.py <input_folder>
Outputs land in <input>_runs/<stl_id>/ (override with --output-folder OUT):
<input>_runs/<stl_id>/
├── best_greedy_parallel_iterative.stl # final reconstruction
├── best_greedy_parallel_iterative.py # equivalent CadQuery program
└── final_iou.json # { final_iou, duration, ... }
Common flags:
| flag | effect |
|---|---|
--max-iterations N | residual cut/union refinement passes (default 1) |
--skip-existing | resume — skip STLs whose final_iou.json exists |
--fillet-chamfer | enable per-edge fillet/chamfer pass (off by default) |
--limit N, --start-from FILE.stl | narrow the input list |
For best throughput on a multi-core box, raise the inner worker pool:
CADFIT_INNER_WORKERS=25 python run_pipeline.py abc_hard
Call from Python directly:
from run_pipeline import process_single_stl
process_single_stl("abc_hard/00013080.stl",
folder_name="abc_hard_runs",
max_iterations=1)
If you find our work helpful, please consider citing:
@article{nehme2026cadfit,
title={CADFit: Precise Mesh-to-CAD Program Generation with Hybrid Optimization},
author={Nehme, Ghadi and Whalen, Eamon and Ahmed, Faez},
journal={arXiv preprint arXiv:2605.01171},
year={2026}
}
Released under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0) license — free for academic and research use; see LICENSE for full terms.
A provisional patent application has been filed covering the CADFit method. Commercial licensing inquiries: ghadi@mit.edu.
For questions, issues, or collaboration, please contact: ghadi@mit.edu
11 commits
Python
95.3%
C++
4.0%