Query2CAD: Generating CAD models using natural language queries

Akshay Badagabettu, Sai Sravan Yarlagadda, Amir Barati FarimaniarXiv 2024 · DOI

Abstract

Query2CAD is a novel framework designed to bridge the gap between natural language and professional engineering design. By utilizing Large Language Models (LLMs) to generate executable Python macros for FreeCAD, the system allows users to create functional 3D CAD models through simple text prompts. A key feature of Query2CAD is its visual self-refinement loop, which employs vision-language models and automated evaluation to iteratively improve model accuracy. Experimental results demonstrate that the system achieves a success rate of up to 76.7% using GPT-4 Turbo, highlighting the potential for AI to democratize complex engineering tasks.

Introduction

Computer-Aided Design (CAD) is essential for modern manufacturing and engineering, yet it remains inaccessible to many due to the steep learning curve of professional software. Traditional 3D generative AI often produces static meshes or point clouds that lack the parametric flexibility required for engineering workflows. Query2CAD addresses these challenges by generating executable CAD data—scripts that can be directly modified and analyzed within standard CAD environments.

Methodology

The Query2CAD framework employs a "generate-and-check" loop to ensure geometric precision and functional utility.

The Query2CAD iterative framework for generating and refining 3D CAD models.

The process begins with an LLM (such as GPT-4 Turbo) translating a user's natural language query into a Python macro for FreeCAD. This macro is executed to produce a 3D model, which is then captured as an isometric image. An automated evaluation system uses VQAScore to compare the image against the original prompt. If discrepancies are found or execution errors occur, a refinement loop is triggered. This loop uses the BLIP2 vision-language model to describe the current output, providing the LLM with the necessary context to "fix" the code in subsequent iterations.

Experimental Evaluation

To evaluate the system, the authors developed a benchmark dataset consisting of 57 user queries categorized by difficulty:

  • Easy: Simple geometric primitives (e.g., cubes, spheres).
  • Medium: Basic shapes with defined spatial relationships.
  • Hard: Complex assemblies requiring multiple operations (e.g., a basketball hoop).

Performance and Refinement

The choice of LLM significantly impacts performance. GPT-4 Turbo outperformed GPT-3.5 across all categories, starting with a 53.6% initial success rate and reaching 76.7% after three refinement iterations. In contrast, GPT-3.5 only reached a 53.4% success rate after refinements.

Example of the refinement process where user feedback improves the initial CAD design of a bookshelf.

A critical finding was the "Power of the First Fix": the most substantial improvement in accuracy typically occurs during the first refinement step. The refinement loop overall contributed a 23.1% increase in success rates, proving that iterative feedback is vital for translating ambiguous natural language into precise geometry.

Discussion and Future Work

While Query2CAD shows promise, it currently relies heavily on proprietary models like GPT-4, as open-source alternatives often struggle with CAD-specific reasoning. Additionally, the "vision-language gap"—where models like BLIP2 fail to capture technical nuances—remains a bottleneck that sometimes requires human intervention.

Future research will focus on scaling the dataset, improving automated technical captioning, and incorporating multi-modal inputs such as hand-drawn sketches to further clarify design intent. By treating code as the universal language of CAD, Query2CAD paves the way for more intuitive and collaborative engineering design tools.

Summary updated

BibTeX
@misc{badagabettu2024query,
  author = {Akshay Badagabettu and Sai Sravan Yarlagadda and Amir Barati Farimani},
  title = {{Query2CAD: Generating CAD models using natural language queries}},
  year = {2024},
  eprint = {2406.00144},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.00144},
}
Figure