Papers
Topics
Authors
Recent
Search
2000 character limit reached

CAD-Coder:Text-Guided CAD Files Code Generation

Published 13 May 2025 in cs.GR, cs.CV, and cs.LG | (2505.08686v1)

Abstract: Computer-aided design (CAD) is a way to digitally create 2D drawings and 3D models of real-world products. Traditional CAD typically relies on hand-drawing by experts or modifications of existing library files, which doesn't allow for rapid personalization. With the emergence of generative artificial intelligence, convenient and efficient personalized CAD generation has become possible. However, existing generative methods typically produce outputs that lack interactive editability and geometric annotations, limiting their practical applications in manufacturing. To enable interactive generative CAD, we propose CAD-Coder, a framework that transforms natural language instructions into CAD script codes, which can be executed in Python environments to generate human-editable CAD files (.Dxf). To facilitate the generation of editable CAD sketches with annotation information, we construct a comprehensive dataset comprising 29,130 Dxf files with their corresponding script codes, where each sketch preserves both editability and geometric annotations. We evaluate CAD-Coder on various 2D/3D CAD generation tasks against existing methods, demonstrating superior interactive capabilities while uniquely providing editable sketches with geometric annotations.

Summary

  • 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

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

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

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

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

Figure 6: Comparative evaluation showing CAD-Coder's superior capabilities over VQ-CAD in key generation tasks.

Figure 7

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.

Cross-Platform Capability

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

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.

Paper to Video (Beta)

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.

Tweets

Sign up for free to view the 1 tweet with 8 likes about this paper.