LLMs for CAD: From Parametric Script Generation to the Gateway of the Physical World

    This article explains how large language models (LLMs) can automate CAD modeling, from translating natural-language design intent into parametric scripts through validating and maintaining the resulting models. It covers the core enablement pipeline, the four technical capabilities that support it, a reference implementation that turns natural language into executable scripts, automatic geometric validation, parametric model operations, 2D/3D and cloud collaboration, a quantitative evaluation framework, and the engineering architecture along with its security and risk controls. It also outlines the current limitations of LLMs in CAD and positions them as a design copilot that augments engineers rather than replacing them.

    Introduction: Why CAD Is the “Gateway to the Physical World”

    CAD software defines a part’s dimensions, geometry, assembly relationships, and manufacturing processes. From a full vehicle body to a single connector terminal, a component must first be defined in CAD before it can move on to CAE (computer-aided engineering) simulation, CAM (computer-aided manufacturing), CNC machining, and quality inspection. In that sense, CAD is the gateway between the digital world and the physical world.

    The efficiency of this gateway has long been constrained. Sketch constraints, feature trees, parametric linkage, and assembly interference checks all follow strict geometric rules. At the same time, the industry is full of non-standard parts, small-batch customization, and frequent design changes. Engineers spend much of their time on repetitive modeling and parameter adjustments, leaving little time for genuine design thinking.

    Parametric modeling scripts are a practical way to ease this problem. A script describes “how to build the geometry” in code, with natural advantages such as version control, bulk reuse, and automatic validation. This article centers on how LLMs can automatically generate and operate CAD modeling scripts, moving from technical principles to implementation methods and engineering deployment, layer by layer.

    1. The Core Enablement Pipeline for LLM-Powered CAD

    A CAD modeling script is an intermediate representation between “natural-language design intent” and “executable geometry.” The full enablement pipeline can be summarized in five steps:

    1. Intent understanding: The LLM parses a natural-language requirement into structured parameters, features, and constraints, such as the basic shape, key dimensions, hole and chamfer requirements, and material or surface-treatment requirements.
    2. Script generation: The structured result is translated into a parametric script that the modeling kernel can recognize, with the entire modeling process driven by a set of named variables.
    3. Kernel execution: The geometry kernel builds the solid step by step according to the script and returns geometry validation results, execution errors, or an exception stack.
    4. Validation and repair: The program automatically determines whether the geometry is valid—for example, whether it is a single closed solid, whether the bounding-box dimensions are reasonable, and whether the key parameters meet requirements. If it fails, the error information is fed back to the model for iterative correction.
    5. Human-in-the-loop confirmation: After previewing the result and checking the key constraints, the engineer confirms the final model and incorporates it into version and change management.

    This pipeline hinges on two critical elements.

    The first is the scripted intermediate representation. Having an LLM output a geometry mesh directly may seem straightforward, but it leads to problems such as being hard to tune, hard to edit, and impossible to trace. A script turns geometry generation into deterministic code execution: every run is reproducible, and changing a single dimension only requires modifying the corresponding variable.

    The second is the execution feedback loop. After a script runs in the geometry kernel, the kernel returns precise errors such as “zero-length edge” or “boolean operation failed.” The LLM uses these to locate and fix problems, which is more reliable than generating a complete answer in one shot. Parametric scripts are therefore the most suitable intermediary layer between “semantics” and “geometry.”

    2. Four Technical Capabilities That Enable LLMs to Operate CAD

    2.1 Geometry Kernels and Parametric Modeling

    The foundation of modern 3D CAD is the geometry modeling kernel. The mainstream technical approaches include boundary representation (B-rep) and parametric/feature-based modeling. The former describes solid boundaries precisely using faces, edges, and vertices; the latter organizes the modeling process through features such as sketches, extrusions, revolutions, sweeps, holes, and chamfers. Design variables are linked through constraints and expressions, so changing one parameter can drive the entire model to update.

    Scripts generated by an LLM must be built on these modeling primitives. When designing the prompt, the following information must be specified:

    • The supported geometric operations and syntax;
    • The coordinate system and unit conventions;
    • Solid validity constraints, such as the result must be a single solid and must not contain self-intersections;
    • The error return format.

    2.2 Multimodal Understanding

    Real design inputs are often not text:

    • Hand-drawn sketches;
    • Dimensioned 2D engineering drawings;
    • Photographs of physical parts;
    • Point-cloud data from reference samples.

    Multimodal LLMs can establish correspondences across modalities: recognizing view layouts, aligning dimension annotations with geometric features, or inferring a part’s basic structure from an image. This makes scenarios such as “drawing-to-model” and “sketch-to-3D” possible. However, such recognition results are usually only a first draft; they need human review of key dimensions and must be combined with 3D reconstruction and reverse modeling to achieve precision.

    2.3 Industrial Data and Knowledge

    Dimensioning conventions, standard-part selection, and material and process constraints are all captured in historical drawings, enterprise design standards, and manual documentation. With techniques such as retrieval-augmented generation (RAG), the model can retrieve similar parts, enterprise design standards, and typical failure cases in real time when generating a script, reducing the bias that comes from “imagining things out of thin air.”

    2.4 Geometric Computation and Verifiable Tools

    Geometric operations have strict mathematical properties. Operations such as boolean operations, offsets, and intersections are highly sensitive to input precision and topology, and must be executed precisely by a geometry kernel or a geometry computation library. An LLM should not perform the geometric computation itself; instead, it is responsible for “orchestration” and “explanation”: calling deterministic geometric tools to complete the computation, then explaining the results and their design implications in natural language.

    3. Reference Implementation: From Natural Language to Executable Scripts

    The following illustrative code demonstrates this pipeline. The code uses Python-like pseudocode. The parametric script follows the common “open document, select datum plane, draw sketch, extrude, drill holes” sequence found in CAD platforms, focusing on how intent parsing, script generation, execution, and automatic repair work together.

    3.1 From Natural Language to Structured Parameters

    1. import re
    2. def parse_spec(text):
    3. """Extract structured design parameters from a natural-language
    4. description. In a real implementation this should be handled by an LLM."""
    5. def match(pattern, cast=float, default=None):
    6. m = re.search(pattern, text)
    7. return cast(m.group(1)) if m else default
    8. return {
    9. "length": match(r"length\s*(?:of)?\s*(\d+(?:\.\d+)?)"),
    10. "width": match(r"width\s*(?:of)?\s*(\d+(?:\.\d+)?)"),
    11. "height": match(r"height\s*(?:of)?\s*(\d+(?:\.\d+)?)"),
    12. "hole_d": match(r"hole(?:\s*diameter)?\s*(\d+(?:\.\d+)?)"),
    13. "hole_num": match(r"(\d+)\s*[-x×]\s*holes?", int),
    14. }

    3.2 Parameter Normalization and Sanity Checking

    Before asking the model to generate a script, run normalization checks to avoid carrying contradictory or missing parameters into the geometry modeling:

    1. def normalize(spec):
    2. """Unify units, validate dimension constraints, and fill in defaults."""
    3. errors = []
    4. if not all(spec[k] and spec[k] > 0 for k in ("length", "width", "height")):
    5. errors.append("Length, width, and height must be positive numbers")
    6. if spec["hole_d"] and spec["hole_d"] >= min(spec["width"], spec["height"]):
    7. errors.append("Hole diameter must not exceed the shortest edge of the mounting face")
    8. if spec["hole_num"] and spec["hole_num"] < 0:
    9. errors.append("Hole count cannot be negative")
    10. return spec, errors

    3.3 Generating the Parametric Script with an LLM

    The prompt must specify clear constraints: the API syntax, units, the requirement to declare all variables, the prohibition on hard-coded dimensions, and the output format.

    1. PROMPT = """You are a CAD automation modeling assistant. Strictly follow
    2. these rules to generate a parametric modeling script:
    3. 1. Use only the given API: new_part(), sketch_rect(), pad(), hole(), save();
    4. 2. Express all dimensions as variables, in millimeters. Hard-coded numbers
    5. are forbidden;
    6. 3. The model must be a single solid, and after boolean operations you must
    7. call validate() to check it;
    8. 4. Output code only, no explanation."""

    A script generated by the model typically looks like this:

    1. # Generated result: parameters are separated from geometry operations,
    2. # so changing a dimension means changing only a variable
    3. L = 120.0 # Length
    4. W = 80.0 # Width
    5. H = 10.0 # Thickness
    6. D = 8.0 # Hole diameter
    7. N = 4 # Hole count
    8. EDGE = 10.0 # Distance from hole center to edge
    9. part = new_part("plate")
    10. sketch_rect(part, plane="XY", length=L, width=W)
    11. pad(part, height=H)
    12. for i in range(N):
    13. x = EDGE if i % 2 == 0 else L - EDGE
    14. y = EDGE if i < 2 else W - EDGE
    15. hole(part, x=x, y=y, z=H, diameter=D, depth="through")
    16. validate(part, single_solid=True)
    17. save(part, format="step")

    The advantage of this style is that a dimension change only requires modifying a variable, and the model automatically recomputes, making it easy to derive series of parts with different specifications in bulk.

    3.4 Execution, Capture, and Automatic Repair

    1. MAX_RETRY = 3
    2. def generate_and_build(spec):
    3. spec, errors = normalize(spec)
    4. if errors:
    5. return None, errors
    6. feedback = ""
    7. for attempt in range(MAX_RETRY):
    8. prompt = PROMPT + f"\nParameters: {spec}" + (f"\nPrevious failure reason: {feedback}" if feedback else "")
    9. script = call_llm(prompt) # Call the LLM to generate the script
    10. ok, result = run_in_sandbox(script) # Execute in an isolated environment
    11. if ok and result.get("valid"):
    12. return result["model"], []
    13. feedback = f"Error code {result.get('code')}: {result.get('message')}"
    14. return None, [f"Automatic repair failed, human intervention required: {feedback}"]

    The isolated sandbox that executes the script must strictly restrict file, network, and CPU access. After a timeout, it should be forcibly terminated to prevent a looped script from consuming resources.

    4. Automatic Validation: From “Looks Correct” to “Actually Usable”

    LLMs commonly produce content that “looks reasonable,” but geometric problems are often hard to spot. It is recommended that the automatic validation stage cover at least the following dimensions:

    • Topological validity: Whether it is a single solid, and whether it contains self-intersections, zero-area faces, or dangling edges;
    • Dimensional sanity: Whether the bounding-box dimensions match the parameters, and whether wall thickness, hole diameter, and chamfers fall within process-permissible ranges;
    • Feature completeness: Whether all the features that should exist—holes, fillets, slots, and so on—have been fully generated;
    • Manufacturability: Basic rule checks such as draft angle, minimum wall thickness, and tool accessibility.

    Only models that pass all checks enter human review; for items that fail, a list of problems is output so engineers can quickly locate the issue.

    5. Parametric Operations: From “Generate Once” to “Continuously Maintain”

    The true value of scripted modeling lies in “operations,” and four capabilities are worth focusing on:

    1. Parametric linkage and bulk derivation: One model corresponds to a set of parameters, allowing rapid generation of a series of parts with different specifications while keeping the structure consistent;
    2. Design rule validation: Encode enterprise design standards as validation rules and run them during generation to reduce rework after the fact;
    3. Change-impact analysis: Because the model is defined by a script, you can compare script differences to locate affected dimensions, assembly relationships, and downstream drawings;
    4. Collaboration and version management: Scripts can be brought into version control and review workflows just like code, so who changed what and why is always traceable.

    6. Collaboration Across 2D, 3D, and the Cloud

    A 2D drawing and a 3D model are two representations of the same design data. If model parameters, annotations, title blocks, and other information can be modeled in a unified way, then when the 3D model changes, the 2D views can update in sync, reducing the manufacturing risk of “drawing-object mismatch.”

    Once design data moves to the cloud, a collaboration loop can form that serves multiple roles:

    • Unified data source: Store models, scripts, validation results, and review records centrally;
    • Access control: Divide view, edit, and approval permissions by project and role;
    • Change workflow: Route key changes through review and approval;
    • Traceability: Every generation and modification can be traced back to the corresponding parameters, script version, and operator.

    In addition, design data can provide a unified source of geometry and parameters for downstream simulation, process planning, and digital twins.

    7. Measuring Effectiveness: Building a Quantitative Evaluation System

    The effectiveness of LLM-assisted CAD should be measured with data. The following metrics are recommended:

    • First-run script success rate: The proportion of scripts that pass on the first execution;
    • Geometry validity rate: The proportion of generated models that pass topological and dimensional checks;
    • Parameter restoration accuracy: The proportion of cases where key dimensions match the design intent;
    • Average repair rounds: The average number of iterations needed to reach an acceptable result;
    • Human intervention rate: The proportion of cases that require engineers to fix things manually;
    • Efficiency comparison: A comparison of the time taken in assisted mode versus manual modeling for the same task.

    It is recommended to build a standardized evaluation set by part category—for example, plate-type parts, shaft-type parts, and housing-type parts—and to cover typical failure samples, forming a sustainable regression baseline.

    8. Engineering Deployment: Architecture, Security, and Risk Control

    8.1 Reference Architecture

    • Access layer: Provides natural-language input, result preview, and one-click application in the design client or a cloud workbench;
    • Orchestration layer: Handles task scheduling, prompt management, model invocation, the execution sandbox, and result validation;
    • Execution layer: The script sandbox runtime and geometry computation services, responsible for the actual modeling;
    • Data layer: Stores model files, scripts, parameters, and review records.

    In a general cloud environment, inference services can typically be hosted on a container platform, design assets stored in object storage, long-running tasks made asynchronous through a message queue, and task success rates and latency distributions tracked through log services and a monitoring and alerting system.

    8.2 Security and Compliance

    • Data isolation: Design data is a core enterprise asset, and the generation and inference processes must stay within a controllable boundary to avoid leaking sensitive geometry data;
    • Operation auditing: All script executions, file exports, and model-replacement operations must leave an audit trail;
    • Permissions and approval: Model check-in and release must go through approval to prevent unvalidated models from entering the production flow;
    • Intellectual property: The ownership of generated results and the compliance of training/reference data sources must be clearly defined.

    8.3 Risk Control

    • Human-in-the-loop: Keep a human confirmation step for critical parts and critical dimensions;
    • Tiered authorization: Low-risk standard parts can be applied automatically, while high-risk parts or those involving safety-critical performance must go through human approval;
    • Rollback capability: Version models and scripts so that any automatic change can be quickly reverted;
    • Progressive rollout: Start with tasks that are highly repetitive and have clear rules, such as standard parts, mounting plates, and connectors, then gradually extend to complex assemblies.

    9. Challenges and Boundaries

    It is important to acknowledge objectively that LLMs still have clear boundaries in CAD:

    • Complex design intent: High-level information such as assembly constraints, motion relationships, and design intent is still difficult to express and reason about fully;
    • Precision and tolerances: LLMs are good at “reasonable structure” but not at “precise dimensions.” Tolerances and fits still need human judgment or a rule engine;
    • Industry-standard differences: Different industries have different requirements for model precision, annotation conventions, and data formats, so a general solution needs industry-specific adaptation;
    • Geometric computation cost: Complex boolean operations and large assemblies are inherently time-consuming, and automation does not eliminate computational complexity.

    A more realistic positioning, therefore, is as a “design copilot”: the LLM takes on repetitive, pattern-based work, while engineers focus on design decisions, process trade-offs, and innovative design.

    Conclusion

    LLMs entering CAD is not about replacing the geometry kernel; it is about adding a layer of “understanding and generation” on top of it. Using parametric scripts as the link, the LLM translates design intent into executable, verifiable, and reusable modeling logic, the geometry kernel guarantees the mathematical correctness of the results, and the engineer makes the final decision.

    Following this path, the value of CAD as a gateway is amplified further: design data changes from a “one-off drawing result” into an “asset that is computable, reusable, and evolvable.” This is also one of the most practically meaningful directions in the convergence of physical AI and industrial software—letting the design capabilities of the digital world flow more smoothly into the manufacturing capabilities of the physical world.