Skip to main content

A minimal, LLM-friendly CAD library in Python

Project description

llmcad

A minimal, LLM-friendly CAD library in Python.

PyPI version Python versions License


Documentation: https://llmcad.org

Source Code: https://github.com/llmcad/llmcad


llmcad is a Python CAD library designed from the ground up to be LLM-friendly. It wraps OpenCASCADE (via OCP) with a minimal, explicit API that makes 3D modeling predictable and debuggable — whether you're writing code yourself or letting an AI agent do it.

BuildCAD AI  Developed by and powering BuildCAD AI — the #1 Text-to-CAD tool.

Why llmcad?

LLMs struggle with 3D spatial reasoning. Traditional CAD APIs make this worse with large surface areas, implicit state, and global coordinate math.

llmcad fixes this with three design principles:

  • Named geometry: Every face and edge has a semantic name (top, front, left_edge). No guessing indices or filtering by coordinates.
  • Face-local coordinates: Position things relative to faces using intuitive local offsets (offset, inset). No global coordinate math.
  • Minimal API: ~28 core concepts. If an LLM can't hold the entire API in context, the API is too big.

Key Features

  • ShapesBox, Cylinder, Sphere centered at origin with named faces
  • SketchesRect, Circle, Ellipse, Polygon, Text, and turtle-style Sketch builder
  • Operationsextrude, revolve, loft, sweep, fillet, chamfer, shell, split, mirror
  • Assemblyplace parts on faces, Assembly for multi-part models
  • Booleans+ (union), - (cut), & (intersect) — operator syntax, no method chains
  • Visual debugging — Multi-view snapshot() renders for LLM feedback loops
  • Exportexport_step, export_stl, export_glb for CAD interchange, 3D printing, and web viewers
  • Immutable — Boolean ops return new bodies. No hidden mutation.

Installation

pip install llmcad

Requires Python 3.10+. Dependencies (cadquery-ocp, numpy, Pillow, vtk) are installed automatically.

Quick Example

A mounting plate with a boss, through-hole, filleted edges, and corner mounting holes — in 15 lines:

from llmcad import Box, Rect, Circle, extrude, fillet

# Base plate
plate = Box(100, 60, 10, color="steel")

# Raised boss on top
boss = extrude(Rect(30, 30).place_on(plate.top), amount=20)
plate = plate + boss

# Through-hole in boss
hole = extrude(Circle(12).place_on(plate.top), through=True)
plate = plate - hole

# Fillet top edges
plate = fillet(plate.top.edges, radius=3)

# Corner mounting holes
for corner in plate.bottom.corners:
    pos = corner.inset(dx=8, dy=8)
    h = extrude(Circle(5).place_on(plate.bottom, at=pos), through=True)
    plate = plate - h

Mounting plate example

How It Works

Named Faces

Every shape comes with semantic face names. No need to filter by normal direction or index into face lists.

box = Box(60, 40, 20)

box.top      # +Z face
box.bottom   # -Z face
box.front    # -Y face
box.back     # +Y face
box.left     # -X face
box.right    # +X face

Face-Local Positioning

Place sketches and holes relative to faces using local coordinates. offset(dx, dy) moves in the face's local frame — dx is always "right" and dy is always "up", regardless of which face you're on.

# Hole offset 20mm to the right on the top face
pos = plate.top.center.offset(dx=20)
hole = extrude(Circle(5).place_on(plate.top, at=pos), through=True)

# Holes at each corner, inset 8mm from edges
for corner in plate.top.corners:
    pos = corner.inset(dx=8, dy=8)  # direction toward center is automatic

Boolean Operations

Combine bodies with Python operators. Each operation returns a new body — the originals are unchanged.

base = Box(80, 60, 10)
boss = extrude(Rect(30, 30).place_on(base.top), amount=20)

result = base + boss   # union
result = base - boss   # cut
result = base & boss   # intersect

Visual Debugging

Render multi-view snapshots for visual verification — essential for LLM feedback loops.

from llmcad import snapshot

snapshot(plate, "plate")  # saves plate.png with front, right, top, and iso views

More Examples

Box
Cylinder
Sphere
Plate with Hole
Filleted Edges
Chamfered Edges
Boolean Subtraction
Corner Holes
Stacked Boxes

See the full examples gallery for all 18 examples with code.

Export

Export to STEP (CAD interchange), STL (3D printing), or GLB (web viewers):

from llmcad import Box, export_step, export_stl, export_glb

box = Box(50, 50, 50, color="steel")

export_step(box, "box.step")  # exact B-Rep geometry
export_stl(box, "box.stl")    # triangulated mesh
export_glb(box, "box.glb")    # binary glTF 2.0 with PBR material

API at a Glance

Category Symbols
Shapes Box, Cylinder, Sphere
Sketches Rect, Circle, Ellipse, Polygon, Text, Sketch
Operations extrude, revolve, loft, sweep, fillet, chamfer, shell, split, mirror
Assembly place, Assembly, RevoluteJoint
Booleans + (union), - (cut), & (intersect)
Debug snapshot, show, show_faces, show_edges, measure
Export export_step, export_stl, export_glb
Types Body, FaceRef, EdgeRef, Position

Full API reference: llmcad.org/api-reference

Dependencies

llmcad builds on:

  • OCP — Python bindings for OpenCASCADE, the industry-standard open-source CAD kernel
  • NumPy — array operations for tessellation and rendering
  • Pillow — image output for snapshots
  • VTK — offscreen multi-view rendering

License

This project is licensed under the terms of the MIT license.


BuildCAD AI   Developed by and powering BuildCAD AI — the #1 Text-to-CAD tool.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmcad-0.3.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmcad-0.3.0-py3-none-any.whl (34.8 kB view details)

Uploaded Python 3

File details

Details for the file llmcad-0.3.0.tar.gz.

File metadata

  • Download URL: llmcad-0.3.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llmcad-0.3.0.tar.gz
Algorithm Hash digest
SHA256 aea857640ffaef7a91c7efbb36f569262c683d2ce387871991d78bfb152a981d
MD5 81e6f6401824b5b24c149fa891ad1ff1
BLAKE2b-256 d4efb5ae369d7a647f49831c4204c1029ab864b18c3005518fda64d477847407

See more details on using hashes here.

File details

Details for the file llmcad-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: llmcad-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 34.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llmcad-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac0e23d753d7ddf006505bde1d56d8ab9314ff337c0dba703d0545d71fd40af5
MD5 cedd1ee7c09ba0307b2febd13fc2781e
BLAKE2b-256 a9362222bb5c6e3dc4049b0b2d51daa7f179b518da489b4f6b77790c32e88ea4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page