[Paper Review] SketchGen: Generating Constrained CAD Sketches
SketchGen uses a transformer-based model with a carefully designed CAD sketch language to generate both primitives and their geometric constraints, enabling constraint-aware CAD sketch generation and auto-constraining of existing sketches. It significantly outperforms the prior SketchGraphs baseline on constrained CAD sketch generation.
Computer-aided design (CAD) is the most widely used modeling approach for technical design. The typical starting point in these designs is 2D sketches which can later be extruded and combined to obtain complex three-dimensional assemblies. Such sketches are typically composed of parametric primitives, such as points, lines, and circular arcs, augmented with geometric constraints linking the primitives, such as coincidence, parallelism, or orthogonality. Sketches can be represented as graphs, with the primitives as nodes and the constraints as edges. Training a model to automatically generate CAD sketches can enable several novel workflows, but is challenging due to the complexity of the graphs and the heterogeneity of the primitives and constraints. In particular, each type of primitive and constraint may require a record of different size and parameter types. We propose SketchGen as a generative model based on a transformer architecture to address the heterogeneity problem by carefully designing a sequential language for the primitives and constraints that allows distinguishing between different primitive or constraint types and their parameters, while encouraging our model to re-use information across related parameters, encoding shared structure. A particular highlight of our work is the ability to produce primitives linked via constraints that enables the final output to be further regularized via a constraint solver. We evaluate our model by demonstrating constraint prediction for given sets of primitives and full sketch generation from scratch, showing that our approach significantly out performs the state-of-the-art in CAD sketch generation.
Motivation & Objective
- Motivate improved generation of CAD sketches by explicitly handling heterogeneous primitives and constraints.
- Propose a structured, token-based language for CAD sketches to enable effective transformer modeling.
- Develop two specialized transformers: one for primitives and one for constraints, informed by syntax trees.
- Demonstrate that constraint-aware generation can be regularized via a solver to produce valid sketches.
Proposed method
- Represent CAD sketches as graphs of heterogeneous primitives linked by constraints.
- Design a formal token-based language for primitives and constraints with a start/end syntax and syntax-tree guidance.
- Quantize continuous primitive parameters via k-means to 256 bins per parameter type.
- Use a transformer decoder as an autoregressive primitive generator conditioned on multiple input sequences (Q, Q3, Q4, QI).
- Implement a pointer-network-based constraint generator that selects primitive indices to form the constraint sequence.
- Train primitive and constraint generators with teacher forcing and cross-entropy loss; apply nucleus sampling during inference.
- Allow post-hoc optimization with a constraint solver to correct quantization errors and improve feasibility.
Experimental results
Research questions
- RQ1Can a structured token-based language enable effective autoregressive generation of heterogeneous CAD primitives and their constraints?
- RQ2Does incorporating syntax-tree guidance (Q3, Q4) improve generation quality over plain sequence modeling?
- RQ3What are the benefits of separating primitive and constraint generation, and of using a pointer-network for constraints?
- RQ4Can generated constraints robustly regularize and correct primitive parameter quantization via a solver?
- RQ5How close is the generated distribution to real CAD sketches in constrained datasets like SketchGraphs?
Key findings
- The model achieves lower negative log-likelihood on test sketches than the SketchGraphs baseline (NLL values: 88.22 for sketches, 8.60 for primitives, 0.61 for constraints).
- Generated sketches exhibit statistics closer to the data distribution than the baseline, as shown by E_stat metrics in generated sequences.
- In ablations, removing syntax-tree inputs (Q3 and Q4) degrades performance, and mixing token types in shared embeddings also harms results.
- Generated constraints can correct primitive parameter quantization errors, and auto-constraining achieves high accuracy (≈98.4% on test-set constraints).
- Post-generation constraint optimization with a solver improves feasibility of sketches (e.g., closes gaps between line endpoints).
- The approach outperforms the primary baseline across both full sketch generation and auto-constraining tasks on the SketchGraphs dataset.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.