IterCAD: Iterative Program Repair for CAD Code Generation from Orthographic Views

Yuchuan Wu, Ke Niu, Haiyang Yu, Zhuofan Chen, Xiangyang Xue, Bin Li

TL;DR

IterCAD shifts the paradigm of generating 3D CAD models from 2D blueprints from a risky "one-shot" prediction to an iterative, self-correcting program repair process. By closing the loop between visual understanding and code execution, IterCAD repeatedly inspects its own intermediate code, fixes structural or parametric errors, and decides exactly when to stop refining.

What Problem Does This Paper Address?

In modern manufacturing and engineering, translating 2D dimension-annotated orthographic drawings (blueprints) into 3D parametric CAD code is a vital but highly challenging task. It requires a model to simultaneously grasp 3D spatial geometry, plan a sequence of modeling operations, and predict precise numerical parameters.

Existing vision-language models (VLMs) typically approach this in a "one-shot" manner, attempting to generate the entire CAD program in a single pass. However, CAD generation is a strongly coupled sequential process. A tiny mistake early on—such as selecting the wrong workplane or slightly miscalculating an extrusion depth—propagates through the entire script, resulting in non-executable code or distorted shapes. Because one-shot models cannot inspect their own outputs or correct mistakes, these early errors are fatal.

Figure 1: Comparison of one-shot CAD generation and IterCAD. While one-shot methods often fail to produce correct CAD programs, IterCAD progressively improves the program through iterative state assessment and revision.

Methods

The authors introduce IterCAD, a unified framework that reformulates CAD generation as a multi-turn revise-or-stop process. Instead of outputting raw code blindly, the model generates a structured response at each turn containing:

  1. <think>: A rationale analyzing the discrepancies between the current CAD state and the target drawing.
  2. <decision>: An explicit choice to either REVISE the code or STOP the process.
  3. <code>: The updated CadQuery script.

To train this iterative agent effectively, the authors developed a three-stage training recipe:

  • Stage I: Initial Draft Generation: The model learns basic vision-to-code mapping to generate an initial executable CAD draft from the input views.
  • Stage II: Revision/Stop Supervision: The model is trained on a specialized dataset to recognize specific geometric errors, execute targeted code modifications, and identify already-correct states.
  • Stage III: Multi-turn RL Optimization: Using Group Relative Policy Optimization (GRPO), the model is optimized over full sampled trajectories. This stage uses a composite reward function evaluating geometric quality (IoU and Chamfer Distance), code syntax, and decision accuracy, teaching the model how to coordinate its revision and stopping behaviors over multiple turns.
Overview of IterCAD's three-stage training framework, spanning initial draft generation, revision/stop supervision, and multi-turn RL optimization.

Datasets

The framework is built and evaluated on CADExpert, an industrial-oriented benchmark for executable and editable CAD code generation.

Because standard datasets only provide final, correct CAD code, the authors constructed a new dataset called IterCAD-RS to provide structured revise-or-stop supervision. They took correct CAD models, converted them into a structured geometric representation (ShapeSpec), and injected controlled semantic perturbations (e.g., altering sketch planes, modifying hole counts, changing extrusion depths). These synthesized "broken" states were paired with repair rationales and the original correct code targets to teach the model how to fix realistic errors.

Key Insights and Ideas

  • CAD Code is Uniquely Suited for Iterative Repair: Unlike free-form text or pixel generation, intermediate CAD outputs are structured, executable programs. They can be compiled and verified geometrically, providing a concrete state that the model can actively inspect and compare against the target specification.
  • Supervised Learning Alone is Insufficient: A key finding in the paper's ablation studies is that simply adding supervised revision data (Stage II) can actually hurt single-turn performance. This is because multi-turn coordination is a complex policy problem. Reinforcement learning (Stage III) is essential to teach the model how to balance when to keep editing and when to stop.
  • Adaptive Stopping Minimizes Overhead: Rather than running for a fixed number of iterations, the model naturally learns an efficient stopping policy, terminating the loop early once geometric consistency is achieved.

Key Results

IterCAD was evaluated using two different open-source backbones: Qwen3.5-9B and Qwen3-VL-8B-Instruct.

  • State-of-the-Art Performance: IterCAD-Q3.5 achieved a massive leap in performance on the CADExpert benchmark, reaching 91.61% Intersection-over-Union (IoU) and 99.33% code executability, outperforming the previous best multi-expert baseline (CME-CAD, which achieved 80.71% IoU).
  • Geometric Precision: The model cut the Mean Chamfer Distance nearly in half, dropping it from 1.00 to 0.5387, indicating much higher dimensional accuracy.
  • Efficiency: Multi-turn inference added only minor computational overhead. For IterCAD-Q3.5, average inference time per sample only increased from 0.338 seconds (one-turn) to 0.397 seconds (multi-turn), because 90.8% of the samples successfully self-corrected and stopped by the second turn.

Limitations and Future Work

While IterCAD bounds its computational overhead through adaptive stopping, multi-turn inference inherently demands more compute than single-pass methods. Additionally, the synthetic errors generated for the IterCAD-RS dataset rely on a predefined taxonomy of perturbations; while extensive, it may not capture every niche or highly complex modeling error encountered in wild, human-written engineering workflows.

The authors suggest that future work could expand this iterative self-repair paradigm to handle more complex multi-part CAD assemblies or adapt it to text-to-CAD generation tasks.

Summary updated

BibTeX
@misc{wu2026itercad,
  author = {Yuchuan Wu and Ke Niu and Haiyang Yu and Zhuofan Chen and Xiangyang Xue and Bin Li},
  title = {{IterCAD: Iterative Program Repair for CAD Code Generation from Orthographic Views}},
  year = {2026},
  eprint = {2608.24020},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.24020},
}
Figure