Source-linked AI summary

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

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

arXiv:2608.24020v1cs.CVcs.AI

TL;DR

Generating executable CAD code from dimension-annotated orthographic views requires precise geometric, procedural, and numerical reasoning, yet one-shot methods cannot inspect and repair intermediate errors. IterCAD reformulates the task as multi-turn program repair over executable CAD states, using revise-or-stop supervision and staged training. On CADExpert, it consistently improves geometric fidelity and executability over strong baselines.

  • Problem

    One-shot vision-language CAD generation cannot inspect intermediate results or correct early errors, risking non-executable or geometrically inconsistent code.

  • Method

    IterCAD repeatedly analyzes executable CAD states, decides whether to REVISE or STOP, and uses IterCAD-RS with three-stage training for generation, revision, and multi-turn optimization.

  • Results

    IterCAD consistently improves geometric fidelity and code executability over strong baselines on CADExpert.

  • Takeaways & Limitations

    Orthographic-view-to-CAD generation is better modeled as iterative repair than one-shot generation, highlighting self-refining generation for executable CAD modeling.

Abstract

from arXiv · show

Generating executable parametric CAD code from dimension-annotated orthographic drawings is a challenging task requiring geometric understanding, procedural reasoning, and precise numerical prediction. Existing vision-language approaches typically formulate this problem as one-shot generation, preventing the model from inspecting intermediate CAD results and correcting early mistakes, often leading to non-executable code or geometrically inconsistent outputs. In this paper, we propose IterCAD, an iterative framework that reformulates orthographic-view-to-CAD generation as a progressive program repair process. Instead of predicting the final CAD code in a single pass, IterCAD repeatedly analyzes the current CAD result, reasons about its discrepancy with the target views, and explicitly decides whether to REVISE the code or STOP the refinement process. To make iterative repair learnable, we further construct IterCAD-RS, a structured revise-or-stop supervision set containing both repairable intermediate CAD states and already-correct states, and develop a three-stage training strategy for initial generation, revision learning, and multi-turn RL optimization. By closing the loop between visual understanding, geometric verification, and code refinement, IterCAD progressively corrects structural and parametric errors. Experiments on CADExpert show that IterCAD consistently improves code executability and geometric fidelity over strong one-shot baselines.

1 Introduction

Generating executable parametric CAD code from dimension-annotated orthographic views requires geometric inference, procedural reasoning, and precise numerical prediction. IterCAD addresses one-shot generation failures by iteratively inspecting executable CAD states and revising or stopping to improve geometric fidelity and executability.

  • CAD code is compact, editable, semantically meaningful, and directly supports downstream modification, validation, and industrial design workflows.
  • Dimension-annotated orthographic drawings provide structural and numerical information, but conversion to executable CAD code requires recovering 3D geometry, operation sequences, and precise numerical values.
  • One-shot generation can propagate early workplane, ordering, topology, or dimensional errors into non-executable or geometrically inconsistent CAD results.
  • Small deviations in dimensions or Boolean operations can make CAD code unusable or significantly alter the final shape.
  • IterCAD repeatedly analyzes the current CAD result, reasons about discrepancies with target views, and explicitly chooses REVISE or STOP.
  • Experiments on CADExpert report improved code executability and geometric fidelity over strong one-shot baselines.
  • IterCAD-RS supplies repairable and already-correct CAD states, while three-stage training covers initial generation, revision learning, and multi-turn policy optimization.

2 Related Work

Prior CAD research includes direct visual-to-code generation, staged structure-and-parameter prediction, verification feedback, and reinforcement learning. IterCAD differs by learning multi-turn repair over intermediate executable CAD states rather than treating refinement as external feedback or optimizing only the final program.

  • IterCAD-RS constructs supervision by injecting one or two geometric perturbations into correct ShapeSpec states to create executable but geometrically inconsistent intermediates.
  • CAD-MLLM and GenCAD directly translate visual inputs into CAD commands or programs, while Img2CAD separates structure prediction from parameter regression.
  • CAD2Program uses a more expressive code representation, and CAD-Llama and CAD-Coder improve structured parametric CAD generation.
  • CADCodeVerify renders generated CAD, performs automated validation questions, and feeds feedback back to the generator for refinement.
  • Existing approaches mainly apply refinement externally to final programs, whereas IterCAD operates on intermediate executable states in a unified learned iterative formulation.
  • Reinforcement-learning methods optimize CAD programs with objectives including executability, geometric accuracy, and alignment with design intent.
  • Existing RL-based methods primarily optimize final-program quality, while IterCAD repeatedly inspects results, chooses REVISE or STOP, and performs adaptive multi-step correction.

3 Iterative Repair Formulation and IterCAD-RS Construction

IterCAD formulates orthographic-view-to-CAD generation as multi-turn program repair, using executable intermediate states, learned REVISE/STOP decisions, and IterCAD-RS supervision to refine CAD code.

  • 3.1 Multi-turn Program Repair Formulation: IterCAD treats orthographic-view-to-CAD generation as iterative program repair rather than one-shot prediction, progressively refining CAD code over multiple turns.The formulation uses the input views and current CAD state to support repeated repair.
  • 3.1 Multi-turn Program Repair Formulation: At turn t, the model conditions on interaction history containing prior rationales, decisions, and CAD code rather than revising the latest code in isolation.This history captures the model’s earlier reasoning process and current code state.
  • 3.1 Multi-turn Program Repair Formulation: Each turn outputs a rationale, a REVISE or STOP action, and CAD code; REVISE continues refinement, while STOP returns the current code as the final prediction.The interaction history is updated by appending each current-turn output.
  • 3.1 Multi-turn Program Repair Formulation: The framework uses executable intermediate CAD states that can be inspected and revised, while learned stopping adapts the number of refinement steps to sample difficulty.Stopping is modeled as an action rather than a hand-crafted post-processing rule.
  • 3.2 IterCAD-RS: Structured Revise-or-Stop Supervision for Iterative Program Repair: IterCAD-RS addresses the supervision bottleneck by pairing repairable intermediate states with positive stopping states built on CADExpert’s SFT split.Standard datasets provide final correct code but not the intermediate states needed to learn revise-or-stop behavior.
  • 3.2 IterCAD-RS: Structured Revise-or-Stop Supervision for Iterative Program Repair: Correct CadQuery programs are converted into ShapeSpec representations, then semantically perturbed to synthesize executable states that remain geometrically inconsistent with target views.The perturbations cover body-level and modifier-level attributes instead of directly altering raw code strings.
  • 3.2 IterCAD-RS: Structured Revise-or-Stop Supervision for Iterative Program Repair: Each wrong state is paired with its correct target and an automatically generated fix_text repair description supervising the rationale, REVISE action, and corrected code.The resulting revision sample maps views and wrong code to repair rationale, REVISE, and correct code.
  • 3.2 IterCAD-RS: Structured Revise-or-Stop Supervision for Iterative Program Repair: Correct or semantically equivalent executable states provide STOP supervision, giving IterCAD-RS explicit training signals for both revision and termination.Thus the dataset covers both intermediate repair and stopping behavior.

4 Methodology

IterCAD uses a three-stage training recipe that moves from initial CAD generation to revise-or-stop learning and trajectory-level optimization on CADExpert.

  • 4 Methodology: The framework trains the model in three stages rather than through end-to-end joint optimization from scratch.The stages provide complementary supervision for generation, revision, and optimization.
  • 4 Methodology: Stage I trains initial CAD code generation from dimension-annotated orthographic views using standard CADExpert pairs.This stage establishes the basic vision-to-code mapping.
  • 4 Methodology: Stage II trains revise-or-stop behavior from intermediate CAD states by reasoning about mismatch between current code and target views.The supervision includes structured intermediate-state interactions.
  • 4 Methodology: CADExpert supplies dimension-annotated orthographic views paired with executable CADQuery code for executable and editable CAD generation.These pairs form the foundation for orthographic-view-to-CAD learning.
  • 4 Methodology: Stage III applies multi-turn reinforcement-learning optimization to improve trajectory-level iterative behavior.The training data progresses from direct generation supervision to structured revision supervision and finally trajectory-level optimization.
  • 4 Methodology: The stages use 8,960 initial-generation pairs, 22,000 revise-or-stop samples, and 4,480 additional samples for multi-turn RL, with Stage III data disjoint from Stages I and II.The staged data allocation separates initial supervision, repair supervision, and RL optimization.

🧠Stage III: Multi-turn RL Optimization

IterCAD progressively trains and optimizes a unified policy for initial CAD generation, intermediate revision, and adaptive stopping across multi-turn repair trajectories.

  • Training progression: The three-stage recipe progresses from initial drafting to structured revise-or-stop supervision and GRPO optimization over complete repair trajectories.This sequencing coordinates capabilities that are related but distinct during iterative inference.
  • Stage I: Initial Draft Generation: Stage I generates an initial executable CAD draft using the same structured interaction format later used for iterative repair.The empty initial state always triggers a REVISE decision before producing the first draft.
  • Stage II: Revision/Stop Supervision: Stage II uses IterCAD-RS to teach targeted correction for inconsistent intermediate states and STOP decisions for already-correct executable states.Outputs preserve the unified <think>, <decision>, and <code> protocol while conditioning on interaction history.
  • Stage III: Multi-turn RL Optimization: Stage III optimizes sampled multi-turn repair trajectories with a trajectory-level reward rather than isolated single-step corrections.This encourages joint use of the generation and revision abilities learned in earlier stages.
  • Reward design: The composite reward combines final CAD quality, structural validity, and decision correctness, using the terminal program state as the effective final code when needed.The final geometric-quality signal is dominant, while format, syntax, and decision terms regularize behavior.

5 Experiments

On CADExpert, IterCAD’s iterative repair pipeline achieves strong geometric fidelity and executability, with ablations showing that multi-turn refinement, intermediate supervision, and trajectory optimization jointly drive the gains. Refinement improves quality across turns, usually stops early, and adds moderate inference cost.

  • Main Results: 91.61% IoU, 0.5387 Mean CD, 0.1038 Med CD, and 99.33% executability make IterCAD-Q3.5 best across all four CADExpert metrics.
  • Main Results: Compared with CME-CAD, IterCAD-Q3.5 raises IoU from 80.71% to 91.61%, lowers Mean CD from 1.00 to 0.5387, and increases executability from 98.25% to 99.33%.
  • Main Results: IterCAD-Q3VL surpasses CME-CAD on all geometric metrics despite using the lighter Qwen3-VL-8B-Instruct backbone, indicating gains across two backbones.
  • Ablation Studies: The full configuration performs best on both backbones, while Stage II alone can hurt single-turn accuracy and executability because revision abilities are not yet used.
  • Ablation Studies: Adding multi-turn inference to Stage I+II raises Qwen3.5-9B IoU from 54.46 to 60.40 and reduces both mean and median Chamfer Distance.
  • Ablation Studies: Stage II supplies intermediate-repair supervision, whereas Stage III coordinates generation, revision, and stopping across turns; their combination outperforms either component alone.
  • Iterative Repair Behavior: IoU increases monotonically across turns, from 89.91 to 91.61 for IterCAD-Q3.5 and from 83.17 to 85.10 for IterCAD-Q3VL, with most gains occurring early.
  • Iterative Repair Behavior: By Turn 2, 90.8% of Q3.5 and 88.4% of Q3VL samples stop, while by Turn 3 the ratios reach 98.9% and 96.5%.

6 Conclusion

IterCAD reframes orthographic-view-to-CAD generation as multi-turn repair over executable intermediate states, supported by revise-or-stop supervision and three-stage training. On CADExpert, it improves geometric fidelity and code executability, with analyses attributing gains to coordinated supervision, trajectory optimization, and adaptive stopping.

  • IterCAD replaces one-shot CAD generation with a multi-turn REVISE/STOP process over executable intermediate CAD states.
  • IterCAD-RS and three-stage training teach initial drafting, intermediate revision, and multi-turn reinforcement-learning optimization.
  • Experiments on CADExpert consistently improve geometric fidelity and code executability over strong baselines.
  • Ablation and inference analyses attribute the gains to structured intermediate supervision, trajectory-level optimization, and adaptive stopping.
Loading 2608.24020v1…