Agent-friendly CadQuery/OCCT abstraction layer with validated geometry operations
Project description
CAiD
An agent-friendly abstraction layer over CadQuery and OpenCASCADE. Every geometry operation returns a ForgeResult with volume tracking, validation, and diagnostics — so silent OCCT failures get caught automatically.
Built for AI agents that need reliable 3D modeling without wrestling with CadQuery's Workplane chaining or OCCT's silent failure modes.
Install
# CadQuery requires conda (OCCT dependency)
conda create -n cadforge python=3.11 -y
conda activate cadforge
conda install -c conda-forge cadquery -y
pip install caid
Quick Example
import caid
# Create a box, add a hole, fillet the edges
box = caid.box(40, 30, 10)
print(box.ok) # True
print(box.volume_after) # 12000.0
with_hole = caid.add_hole(box, radius=2.7, depth=10)
filleted = caid.fillet(with_hole, radius=1.5, edge_selector=">Z")
# Export
caid.to_stl(filleted, "bracket.stl")
caid.to_step(filleted, "bracket.step")
# Check validity
report = caid.check_valid(filleted)
print(report) # {'is_valid': True, 'n_faces': 10, ...}
Key Concepts
ForgeResult
Every operation returns a ForgeResult instead of a raw shape:
result = caid.box(10, 20, 30)
result.ok # True if valid=True AND shape is not None
result.shape # The CadQuery shape (or None on failure)
result.valid # Geometry validity flag
result.volume_before # mm³ (for operations that modify geometry)
result.volume_after # mm³
result.surface_area # mm²
result.diagnostics # {"reason": ..., "hint": ...} on failure
result.unwrap() # Returns shape or raises ValueError
Stateless API
All functions are pure — no hidden state, no Workplane chaining. Pass shapes in, get ForgeResults out.
a = caid.box(10, 10, 10)
b = caid.cylinder(3, 20)
cut = caid.boolean_cut(a, b) # Accepts ForgeResult or raw shape
Validated Booleans
Boolean operations check volume before and after. If a union doesn't increase volume, you get valid=False with a diagnostic hint.
result = caid.boolean_union(a, b)
if not result.ok:
print(result.diagnostics) # {"reason": "volume did not increase", "hint": "shapes may not overlap"}
Swappable Backend
CAiD routes all geometry through a BackendProtocol. The default is CadQuery, but the protocol is designed so a direct OCCT backend could be swapped in.
backend = caid.get_backend() # Current backend instance
Available Functions
| Category | Functions |
|---|---|
| Primitives | box, cylinder, sphere, cone, torus |
| Booleans | boolean_union, boolean_cut, boolean_intersect |
| Operations | extrude, sweep, fillet, chamfer |
| Transforms | translate, rotate, mirror, scale |
| Healing | check_valid, heal, simplify |
| Assembly | Assembly, Part |
| Export | to_stl, to_step, to_brep, from_step, from_brep |
| Preview | preview, preview_multi |
| Compound | array_on_curve, belt_wire, pulley_assembly |
See SPEC.md for the complete API specification.
Development
pip install -e ".[dev]"
pytest tests/ -v
Acknowledgments
CAiD was co-developed by Adam Steen and Claude (Anthropic).
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file caid-0.1.0.tar.gz.
File metadata
- Download URL: caid-0.1.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd274692116578fdcb5e5ab159a47c1081261b027e3624bc101762932d4ebc8
|
|
| MD5 |
a5b1faab46ba8fbc975699c869bd288c
|
|
| BLAKE2b-256 |
34e00e07aa0df55506aea384f5f8ebac56cb05494ac44d9a778ea7182284e584
|
File details
Details for the file caid-0.1.0-py3-none-any.whl.
File metadata
- Download URL: caid-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
966cad51711f3d11d7f49cd1d6ba76022ec79f6d9989efdd18da403e4e0f5438
|
|
| MD5 |
896b5e28f5d88e7594c650ceaa82aaaf
|
|
| BLAKE2b-256 |
b431c18a841076a3327e9815a1bc885a794b6b98a94dd25998c51df93dfc6376
|