Abstract
Researchers have developed a pipeline to generate precise, modifiable 3D mechanical parts by fine-tuning a code-generation LLM to write Constructive Solid Geometry (CSG) scripts. Unlike traditional 3D AI that produces "fuzzy" triangle meshes, this approach generates clean Python code that defines geometry through mathematical primitives, enabling high-precision CAD modeling via natural language.
Introduction
In the world of 3D generation, most AI models (like DreamFusion or MeshGPT) output meshes—collections of thousands of tiny triangles. While suitable for video games and visual media, meshes are often inadequate for mechanical engineering. They are imprecise (a "round" hole is actually a polygon), difficult to edit parametrically, and lack the mathematical "truth" required for manufacturing.
Engineers prefer Boundary Representation (BREP) or Constructive Solid Geometry (CSG), where shapes are defined by mathematical primitives (cubes, cylinders) and Boolean operations (union, subtraction). However, automating the creation of these models is difficult because the underlying data structures are complex and less "regular" than pixel grids or point clouds. This research bridges the gap by treating 3D design as a code-generation task.
Methodology
The authors propose a novel pipeline that transforms 3D geometry into a format a Large Language Model (LLM) can understand:
- Decomposition: They use a tool called GEOUNED to convert standard CAD files (.STEP) into CSG sequences.
- Graph to Sequence: The 3D model is represented as a graph of "half-spaces" (planes and cylinders). This graph is then linearized into a sequence that describes how these surfaces combine to form "cells."
- Code Generation: These sequences are converted into Python scripts using the OpenMC library. This turns a 3D part into a readable script where surfaces are variables and cells are combinations of those variables.
- Natural Language Annotation: To make the model "controllable," they rendered 2D images of the parts and used GPT-4o to write short, informal descriptions (e.g., "U-shaped bracket with a hole").
- Fine-Tuning: They fine-tuned DeepSeek-Coder-1b, a lightweight code-generation model, on this dataset. The model was trained to "complete" a geometry—taking a partial script and a text prompt to generate the remaining 3D structure.
Dataset and Training
The study utilized the ABC dataset, a massive collection of one million CAD models.
- Curation: The authors filtered the dataset for parts containing only planes and cylinders oriented along the primary axes, limiting complexity to models with 2 to 10 "cells."
- Final Count: The resulting curated dataset contained 37,220 parts, split 90/10 for training and testing.
- Augmentation: They increased data variety by varying where the code sequences were "cut" (input vs. output) and shuffling the order of the geometric primitives.
Key Insights
- 3D as a Language Problem: By representing 3D geometry as Python code, the researchers leveraged the pre-existing "reasoning" capabilities of LLMs trained on millions of lines of software code.
- Precision over Approximation: Because the output is code defining mathematical surfaces, the resulting models have infinite precision. A cylinder is a true cylinder, not a 20-sided approximation.
- Positional Awareness: The model demonstrates "geometric understanding" by successfully reusing surface variables defined in the input to create new cells in the output at the correct spatial coordinates.
- The "Simple is Hard" Paradox: While the model is excellent at generating simple geometries, the authors found that describing complex 3D parts in natural language is a bottleneck—both for humans and AI.
Key Results
- Syntactic Success: The fine-tuned model achieved a 92.7% to 97.3% success rate in generating code that was both syntactically correct and logically sound (all cells connected, no overlaps).
- Text Control: Adding natural language descriptions significantly increased the likelihood of the model hitting the "ground truth" for simpler parts (1-2 cells).
- Spatial Completion: The model proved capable of completing geometries based on positional input, effectively "filling in the blanks" of a mechanical part in a plausible way.
- Complexity Scaling: Performance remains high for simple parts but drops as the number of cells increases, particularly when the model is asked to follow text instructions for complex shapes.
Limitations and Future Work
The current approach is a "proof of concept" with several constraints:
- Primitive Palette: The model is currently limited to planes and cylinders aligned with the X, Y, and Z axes. It cannot yet handle spheres, tori, or slanted surfaces.
- Textual Complexity: As parts get more complex, short text descriptions become insufficient. The authors suggest that future CAD tools might combine text with direct surface selection for better control.
- Modification vs. Generation: While the model can expand a geometry, it isn't yet designed to modify existing parameters (like changing the diameter of an existing hole), which is a key requirement for a full AI CAD assistant.
The authors envision future iterations leveraging larger LLMs and more diverse datasets to handle the full breadth of modern mechanical engineering design.
Summary updated