Drawing2CAD: Automated CAD from 2D Drawings
- Drawing2CAD is a computational framework that converts 2D vector drawings into precise, editable, parametric CAD models using sequence-to-sequence learning.
- It employs a dual-decoder transformer architecture to separately predict discrete CAD commands and continuous parameters for improved model fidelity.
- The framework leverages a soft target distribution loss and the CAD-VGDrawing dataset to enhance reconstruction accuracy and preserve design intent.
The Drawing2CAD framework denotes a class of computational systems that automate the generation of parametric CAD models directly from vectorized 2D engineering drawings, with preservation of geometric precision, procedural intent, and editability. Unlike earlier generative methods that treat CAD as a shape inference or mesh generation task, Drawing2CAD specifically targets the industrial workflow where standardized drawings (e.g., vector or SVG sketches) are the source specification, and the output is a procedural CAD model constructed as a sequence of parametric operations. This approach is characterized by the explicit learning of mappings from vector primitives to structured CAD commands, the decoupling of command type and parameter prediction, and loss formulations that accommodate the inherent flexibility of CAD parameterization, as exemplified in the recent model described in "Drawing2CAD: Sequence-to-Sequence Learning for CAD Generation from Vectorized Drawings" (Qin et al., 26 Aug 2025).
1. Formal Problem Setting and Rationale
The primary objective of Drawing2CAD is to transform a vectorized drawing — where represents geometric primitives such as lines, arcs, or circles—into a procedural CAD program . Here, denotes the type of CAD operation (e.g., line, arc, extrude), and encapsulates its continuous parameters (coordinates, radius, angles, etc.). The generated sequence must enable exact or near-exact reconstruction of the design’s geometry within a standard CAD kernel, while also encoding the procedural construction history required for downstream editing.
Traditional generative CAD approaches generally operate on point clouds, voxel grids, or meshes, often failing to align with the design intent encoded in engineering drawings and not facilitating editability or parametric design modification.
2. Representation of Vector Primitives and CAD Commands
A central innovation is the development of a network-friendly representation of vector primitives and CAD commands:
- Each drawing primitive is represented as a parameterized token, including both type and numeric parameters: for example, a line as .
- The sequence is encoded to preserve ordering and grouping semantics as found in the original vector file (e.g., SVG path data).
- Distinct tokens are allocated for explicit command boundaries, optional loops, and attribute switches if present in the drawing file.
On the output side, the CAD command sequence is similarly structured, with discrete command type tokens and their associated parameter vectors. These are designed to map 1:1 (or N:M, for compound constructs) with vector drawing primitives, enabling precise correspondence.
This explicit, structured encoding is crucial for neural sequence models, as it reduces ambiguity and information loss relative to raw pixel or point data.
3. Dual-Decoder Transformer Architecture
The Drawing2CAD framework employs a dual-decoder transformer architecture tailored for the hybrid discrete-continuous nature of CAD command sequences:
- Command Decoder: Responsible for predicting the sequence of command types (). This branch produces a categorical distribution over possible CAD operations at each step based on the current context and previous tokens.
- Parameter Decoder: For each predicted command type, a separate decoder estimates the associated continuous parameters ()—such as coordinates, angles, or radii—using regression outputs appropriately conditioned on the selected command type.
These decoders operate either sequentially or in parallel, with cross-attention mechanisms to ensure that parameter predictions are coherent with respect to the discrete command decisions.
A simplified schematic pseudocode editor's term:
1 2 3 4 |
drawing_seq = encode_input_svg(vectorized_drawing)
command_types = CommandDecoder(drawing_seq)
parameters = ParameterDecoder(drawing_seq, command_types)
cad_sequence = zip(command_types, parameters) |
This dual-decoder construction improves specialization and reduces instability that commonly arises in end-to-end sequence models tasked with both discrete and continuous prediction.
4. Loss Function: Soft Target Distribution
Precision in CAD parameterization often admits tolerances; multiple valid parameter values may yield functionally equivalent models. To accommodate this, Drawing2CAD introduces a soft target distribution loss:
where is a non-binary (soft) distribution over admissible parameter values, and the model’s predicted parameter distribution for each slot. This formulation encourages the network to capture the flexibility in CAD construction, rather than committing to an overconstrained “one-hot” target.
Such a loss reduces the penalty for minor discrepancies and improves the robustness of generated CAD sequences, especially for models where multiple parametric realizations are permissible.
5. Dataset: CAD-VGDrawing and Experimental Validation
The CAD-VGDrawing dataset is introduced as a benchmark, containing paired samples of:
- Vectorized engineering drawings (SVG or equivalent) as input
- Complete procedural CAD command histories as output
The dataset captures not only geometric information but also construction sequences, ensuring that the model learns both shape recreation and design intent.
Experiments demonstrate:
- Performance gains over baseline methods in sequence accuracy, geometric fidelity, and procedural validity
- Ablation studies reveal significant contributions from (a) explicit vector primitive representation, (b) the dual-decoder design, and (c) the soft target distribution loss
- Both quantitative (e.g., accuracy, loss) and qualitative (visual, semantic) metric improvements in CAD reconstruction compared to rule-based and single-decoder models
The CAD-VGDrawing dataset and codebase are available at [https://github.com/lllssc/Drawing2CAD].
6. Implications for Industrial CAD Modeling
Drawing2CAD aligns CAD generative modeling with established engineering workflows that commence from 2D vector drawings. The sequence-to-sequence paradigm supports automation of:
- Design intent preservation, as command histories can be programmatically modified
- Downstream CAD automation, including parametric editing, simulation, and manufacturing preparation
- Integration with procedural or parametric kernels for further geometry refinement and constraint-based modification
By being able to synthesize complete CAD command histories from sketches, the framework positions itself as a core enabler for “drawing-to-procedure” transformations in industrial, engineering, and creative settings, marking a step forward from geometry-only or mesh-based approaches.
7. Limitations and Future Directions
Current limitations include:
- Dependence on the domain and coverage of vector primitive representations; unusual sketch conventions or non-standard vector formats may degrade performance
- The model’s generalization outside the CAD-VGDrawing dataset is bounded by the diversity of training data
- Parametric command support is contingent on the expressiveness found in the dataset; rare or highly specialized operations may require further curation and annotation
Potential extensions involve:
- Expansion of the training set to cover more CAD operations and drawing conventions
- Inference-time integration with constraint solvers to resolve under- or over-constrained outputs
- Coupling with bidirectional editing or solution-space exploration tools to further reduce designer iteration cycles
In summary, the Drawing2CAD framework (Qin et al., 26 Aug 2025) establishes a data-driven, sequence-to-sequence modeling paradigm for converting vectorized engineering drawings into fully procedural, parametric CAD programs. Its architecture, loss design, and empirical results point towards more automated, accurate, and editable CAD generation workflows in line with longstanding industry practice.