LLM-Assisted CAD Modeling: Technical Pipeline and Risk Boundaries

    Large language models can turn natural language requirements into structured CAD parameters, but they should never generate geometry directly. This article outlines a deterministic pipeline—model proposes, program validates, engineer approves—and walks through three practical application patterns with a runnable Python and CadQuery example. You will learn where LLMs fit in parametric modeling, what validation checks are required, and how to keep humans accountable for manufacturability.

    1. Set the Boundary First: The Model Proposes, the Program Validates

    Computer-aided design (CAD) software typically provides both a graphical interface and a scripting interface. The graphical interface suits interactive work, while the scripting interface is better for parametric, batch, and reproducible modeling tasks.

    Large language models (LLMs) are well suited to converting natural language requirements into structured parameters or modeling instructions. They are not suited to outputting geometric results directly, for three reasons: dimensions may fall outside process limits, structures may conflict with assembly relationships, and the output format may be unstable.

    This article therefore recommends a fixed pipeline: the model outputs structured parameters, a deterministic program performs range checks, geometry construction, and file export, and an engineer signs off on the result. The program only parses JSON data produced by the model—it never executes arbitrary code generated by the model.

    Human review and clear accountability matter just as much. Model output is a draft only. Whether drawings and models can be used for manufacturing must be confirmed by the responsible process, structural, and quality engineers. The model cannot replace process or safety sign-off.

    2. Three Typical Application Patterns

    In real projects, LLM involvement in CAD modeling falls into roughly three categories. Each requires clearly defined inputs, outputs, validation points, and human review points.

    Pattern 1: From Requirements to an Initial Model

    The input is a natural language description, for example: “A plate 120 mm long, 80 mm wide, and 6 mm thick, with a 10 mm through-hole in the center.”

    The model outputs structured parameters. Units are unified to millimeters, the coordinate system is the default world coordinate system, the origin sits at the center of the plate, the length runs along the X axis, the width along the Y axis, and the thickness along the Z axis. Example output:

    1. {"unit": "mm", "length": 120, "width": 80, "thickness": 6, "hole_diameter": 10}

    Validation checks whether all fields are present, whether values fall within process limits, and whether the ratio of hole diameter to the plate’s shorter side is reasonable. On failure, the system returns the error list to the user and asks for a revised or clarified description. The system does not silently fix errors, because silent corrections prevent users from judging whether the final model matches the original requirement.

    Pattern 2: Parameter Changes to a Single Part

    The input is an existing model’s parameter file plus a change request, such as “change the thickness to 8 mm.” The model outputs only a patch containing the fields to be modified, for example {"thickness": 8}.

    The processing flow is: read the original parameters, merge the patch, revalidate, rebuild the geometry, and compare against the original version. The model may accidentally modify adjacent fields or write the wrong unit, so the program must list every field that changed before and after. Only after the user confirms does the system rebuild and export.

    Pattern 3: Geometry and Material Adjustments

    Geometric adjustments include features such as chamfers, hole positions, and patterns. The model may only select from a predefined feature list—it cannot invent feature names. Materials may only be selected from the enterprise material library. The model must not fabricate material grades or mechanical property data.

    Validation covers: whether the material name exists in the library; whether properties such as density are taken from the library as the source of truth; and whether the weight estimate after the geometric change is consistent with the reference value. If the deviation exceeds a set threshold, the system should flag the result for human review.

    3. Example Code and Runtime Environment

    The example uses Python 3.10 or later and the open-source parametric modeling library CadQuery 2.4, which is built on the OpenCASCADE geometry kernel. The example only covers a rectangular plate with a through-hole, to demonstrate the pipeline structure—it is not directly usable for real manufacturing.

    Environment setup steps:

    1. Create an isolated virtual environment: python -m venv .venv, then activate it.
    2. Install the dependency: pip install "cadquery==2.4.0"
    3. Run permissions: the program only reads parameter files inside the project and writes only to the designated output directory. It does not connect to production PLM or document management systems.

    Save the example code as build_plate.py:

    1. import json
    2. import os
    3. import cadquery as cq
    4. # Parameter limits (unit: mm). Maintained by process engineers, not modified by the model.
    5. LIMITS = {
    6. "length": (20.0, 300.0),
    7. "width": (20.0, 200.0),
    8. "thickness": (1.0, 20.0),
    9. "hole_diameter": (3.0, 30.0),
    10. }
    11. def validate(params):
    12. errors = []
    13. if params.get("unit") != "mm":
    14. errors.append("unit must be mm")
    15. for key, (low, high) in LIMITS.items():
    16. if key not in params:
    17. errors.append(f"missing field: {key}")
    18. continue
    19. value = params[key]
    20. if isinstance(value, bool) or not isinstance(value, (int, float)):
    21. errors.append(f"{key} must be a number")
    22. elif not low <= value <= high:
    23. errors.append(f"{key}={value} out of range [{low}, {high}]")
    24. if not errors:
    25. if params["hole_diameter"] >= 0.5 * min(params["length"], params["width"]):
    26. errors.append("hole diameter too large relative to the plate's shorter side")
    27. return errors
    28. def build_plate(params):
    29. solid = cq.Workplane("XY").box(
    30. params["length"], params["width"], params["thickness"]
    31. )
    32. return solid.faces(">Z").workplane().hole(params["hole_diameter"])
    33. def run(json_text, out_path):
    34. try:
    35. params = json.loads(json_text)
    36. except json.JSONDecodeError as exc:
    37. raise ValueError(f"invalid JSON from model: {exc}")
    38. errors = validate(params)
    39. if errors:
    40. raise ValueError("validation failed: " + "; ".join(errors))
    41. result = build_plate(params)
    42. os.makedirs(os.path.dirname(out_path), exist_ok=True)
    43. cq.exporters.export(result, out_path)
    44. return out_path

    The run function parses the JSON text produced by the model, validates it, builds the geometry, and exports the result to the specified path. If parsing or validation fails, it raises an error instead of silently proceeding.

    4. Closing Perspective

    The core idea is simple: let the LLM do what it is good at—translating intent into structured data—and let deterministic code do what it is good at—checking constraints, building geometry, and producing files. Keep model-generated code out of the execution path, surface every change to the user, and keep manufacturing sign-off firmly in human hands.