CADMorph: Geometry‑Driven Parametric CAD Editing via a Plan–Generate–Verify Loop

Weijian Ma, Shizhao Sun, Ruiyu Wang, Jiang Bian

TL;DR

CADMorph introduces an iterative "Plan–Generate–Verify" framework for geometry-driven CAD editing, allowing users to update a parametric construction sequence simply by providing a target 3D shape. By orchestrating a latent diffusion model and a specialized Large Language Model (LLM), it achieves high shape fidelity and preserves design intent without requiring expensive, hard-to-find triplet training data.

What Problem Does This Paper Address?

In Computer-Aided Design (CAD), every object has a "dual" nature: it exists as a parametric construction sequence (a series of commands like Extrude or Line) and a visible geometric shape.

Geometry-driven parametric CAD editing transforms an original sequence to match a target geometry.

When an engineer needs to change a part's shape—perhaps to make it more aerodynamic or to fit a new component—they must manually hunt through hundreds of lines of "code" (the sequence) to find which parameters to tweak. This is tedious and error-prone. While AI has made strides in generating CAD from scratch, geometry-driven editing is much harder because:

  1. Structure Preservation: You want to change the shape while keeping the original design logic intact.
  2. Semantic Validity: The resulting code must actually "run" and make sense in a manufacturing context.
  3. Data Scarcity: There are no massive datasets containing "Original Sequence + Target Shape + Updated Sequence" triplets to train on.

Methods

CADMorph tackles these challenges using an iterative loop that leverages two domain-specific foundation models:

  1. Parameter-to-Shape (P2S) Model: A latent diffusion model trained to map CAD sequences to 3D voxelized shapes (SDFs).
  2. Masked-Parameter-Prediction (MPP) Model: A Large Language Model (based on Llama-3) fine-tuned to "infill" missing segments of CAD code.
The CADMorph Plan-Generate-Verify framework utilizing P2S and MPP models.

The Plan–Generate–Verify loop works as follows:

  • Plan: The system analyzes the cross-attention maps inside the P2S model. By looking at which parts of the CAD sequence "attend" to the areas of the shape that don't match the target, it pinpoints exactly which lines of code need modification and replaces them with a [MASK] token.
  • Generate: The MPP model takes the masked sequence and generates multiple candidate "infills." Because it was trained on vast amounts of CAD data, it ensures the new code is syntactically correct and follows design conventions.
  • Verify: The P2S model projects these candidates and the target shape into a shared latent space. The candidate that is mathematically "closest" to the target shape is selected for the next iteration.

Crucially, neither model requires "triplet" data; they are trained on standard, unpaired CAD datasets.

Datasets

  • Training: The authors used the DeepCAD corpus, containing roughly 130,000 CAD models.
  • Evaluation: Testing was performed on a 2,000-case subset of the CAD-Editor dataset.
  • Processing: Shapes were converted into voxelized Truncated Signed Distance Fields (tSDFs) for the diffusion model.

Key Insights and Ideas

  • Attention as a Diagnostic Tool: One of the most clever insights is using cross-attention maps—originally designed for text-to-image alignment—to localize errors in CAD code. It treats the CAD sequence like a "prompt" and the 3D shape like the "image," identifying which "words" (parameters) are responsible for specific geometric features.
  • Test-Time Scaling: Instead of trying to get the edit right in one shot, CADMorph uses "test-time scaling." It spends more computational effort during inference by generating many candidates and using a verifier to pick the best one, a strategy that has recently proven highly effective in LLM reasoning.
  • Preserving Manufacturing Intent: Unlike "reverse engineering" models that might rewrite the entire file from scratch, CADMorph’s masking strategy ensures that if you only want to change the size of a hole, the rest of the part's construction history remains untouched.

Key Results

CADMorph significantly outperformed general-purpose models (GPT-4o) and specialized CAD baselines (CAD-Diffuser, FlexCAD):

  • Shape Fidelity: Achieved an Intersection over Union (IoU) of 0.687, nearly 25% higher than the next best specialized baseline.
  • Accuracy: The Mean Chamfer Distance (CD)—a measure of surface error—was reduced to 0.009, compared to 0.029 for FlexCAD and 0.107 for GPT-4o.
  • Robustness: The Invalid Rate (IR) (how often the code failed to render) was only 3.1%, whereas GPT-4o failed 25.1% of the time.
  • Qualitative: Human evaluators consistently ranked CADMorph as the best at matching the target shape while preserving the original sequence's logic.

Limitations and Future Work

  • Inference Latency: Because the framework is iterative and involves running a diffusion model and an LLM multiple times, it is slower than single-pass methods. The authors suggest future work could involve parallelizing the generation and verification stages.
  • Dataset Complexity: The study relies on the DeepCAD dataset, which consists of relatively simple parts. Real-world industrial CAD assemblies are far more complex, and the authors highlight the need for richer, more challenging benchmarks to push the technology further.
  • End-to-End Distillation: The authors propose using CADMorph as a "data engine" to synthesize the very triplets that are currently scarce, which could eventually be used to train a faster, end-to-end editing model.

Summary updated

BibTeX
@inproceedings{ma2025cadmorph,
  author = {Weijian Ma and Shizhao Sun and Ruiyu Wang and Jiang Bian},
  title = {{CADMorph: Geometry‑Driven Parametric CAD Editing via a Plan–Generate–Verify Loop}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=jCuEeQF7uP},
}
Figure