- The paper introduces a novel framework that converts natural language into editable, annotated Dxf-format CAD files.
- It employs a comprehensive dataset of 29,130 CAD files and leverages Python scripting with LoRA training for robust CAD generation.
- Experiments show superior performance over existing models, enhancing cross-platform usability in popular CAD software.
CAD-Coder: Text-Guided CAD Files Code Generation
CAD-Coder introduces a novel framework for synthesizing CAD models and sketches from natural language descriptions, addressing limitations in current CAD generation techniques which lack editability and geometric annotation features. Through a pipeline that leverages a comprehensive dataset and the LoRA training method, CAD-Coder transforms text inputs into detailed and editable CAD files.
Pipeline and Dataset Construction
CAD-Coder functions by generating script codes that produce CAD files in Dxf format while retaining the ability to annotate 3D models and 2D sketches. This process is illustrated by a detailed pipeline (Figure 1), where the CFSC Dataset serves as a pivotal component. This dataset consists of a significant collection of 29,130 CAD files, encompassing both annotated and non-annotated examples, which are linked to corresponding natural language descriptions to facilitate learning within the DeepSeek-R1-Distill-Llama-8B model.
Figure 1: The pipeline of CAD-Coder shows the integration of script code generation and its execution into Dxf files, enabling cross-platform usage.
A key enhancement in this framework is the capability to produce editable CAD models via text guidance, enhancing usability across various CAD platforms (Figure 2). The dataset emphasizes annotation capabilities, as demonstrated in the inclusion of geometric primitives and extensive annotation details (Figure 3).
Figure 3: The dataset includes diverse primitive types, facilitating robust annotation capabilities in CAD-Coder.
Methodology
CAD Generation Approach
The CAD-Coder framework is reliant on Python to develop editable CAD sketches and models. The Dxf format acts as an intermediary, providing a universally recognized and editable format for CAD files. Python's scripting, enabled by libraries like ezdxf, is crucial for establishing a model that can discern and generate script codes from textual queries.
Script Code Structure and Dataset
CAD-Coder makes use of a unified script code structure to facilitate model training, involving a coherent assembly of library functions, model construction, and main functions (Figure 4). By employing randomization algorithms, diverse script codes are generated to reflect various configurations of CAD models.
Figure 4: Script code structure demonstrating the modular arrangement of function importation and execution for model generation.
To refine differentiation in script code segments and to bolster learning accuracy, instructions for handling similar segments and adding targeted comments are applied (Figure 5).
Figure 5: Illustration of handling script segments prone to confusion by enhancing them with instructive comments.
Experiments and Model Comparison
The performance of CAD-Coder, evaluated against state-of-the-art CAD generation models such as VQ-CAD, manifests clear advantages in generating both annotated and non-annotated CAD sketches (Figures 6 and 7). The model's proficiency is supported by evaluation metrics such as ACC-F, ACC-P, and ACC-G, which demonstrate CAD-Coder's efficacy in function accuracy, parameter accuracy, and graphical accuracy respectively.
Figure 6: Comparative evaluation showing CAD-Coder's superior capabilities over VQ-CAD in key generation tasks.
Figure 7: Demonstrating CAD-Coder's annotation accuracy in comparison to the ground truth.
Performance metrics underscore CAD-Coder's proficiency across multiple dimensions, with notable enhancements in Pass@k metrics and average parsing rates compared to other LLMs (Table - included in text as Figure 8 indicator). This is particularly evident in tasks that generate complex CAD models and annotated sketches, reinforcing CAD-Coder's advantage in real-world applicability.
True cross-platform viability of CAD-Coder is attained through the generation of Dxf files, permitting seamless integration across varied CAD software environments, such as AutoCAD and SolidWorks (Figure 2). This cross-platform utility is a marked improvement over models reliant on proprietary or non-transferrable command sequences.
Figure 2: Demonstrating CAD-Coder’s cross-platform capabilities, with Dxf files accessible in major CAD software applications.
Conclusion
CAD-Coder represents a substantial advance in text-guided CAD generation, overcoming the limitations of existing models by providing annotated, editable CAD outputs through an innovative dataset and training approach. The system enables efficient and accurate CAD development, promising substantial impact across industries reliant on iterative and interactive design processes, with future expansions likely to enhance its adaptability to broader engineering components and annotation types.