Reactive Parametric CAD for marimo notebooks
Project description
marimo-cad
Reactive Parametric CAD for marimo notebooks.
Built on build123d + three-cad-viewer.
Build interactive 3D CAD models with sliders that update in real-time without losing your camera position.
Why marimo-cad?
| Use Case | Native build123d | marimo-cad |
|---|---|---|
| Quick visualization | Just return the object | Overkill |
| Parametric design with sliders | Camera resets on every change | Camera preserved |
| Named multi-part assemblies | No | Yes, with tree view |
| Export (STL/STEP/GLTF) | Manual | Built-in |
Installation
uv add marimo-cad
Quick Start
import marimo as mo
from build123d import Box
import marimo_cad as cad
size = mo.ui.slider(10, 50, value=20, label="Size")
viewer = cad.Viewer()
box = Box(size.value, size.value, size.value)
viewer.render(box)
mo.vstack([size, viewer])
Examples
See notebooks/ for complete examples:
bookshelf.py- Parametric bookshelfvase.py- Parametric vase with STL export
Viewer Features
- Mouse: Rotate (drag), pan (right-drag), zoom (scroll)
- Tree view: Toggle part visibility
- Clipping planes: Slice along X/Y/Z
- Measurement: Distance and angles
Limitations
- Large models (>100k triangles) may be slow to tessellate
- Selection events not yet exposed to Python
Development
uv sync && cd js && npm install && npm run build && cd ..
uv run pytest tests/ # 34 tests
uv run ruff check src/ --fix # Lint
API Reference
Viewer
viewer = cad.Viewer(width="100%", height=600)
viewer.render(shapes)
| Parameter | Type | Default | Description |
|---|---|---|---|
width |
str | int |
"100%" |
CSS width or pixels |
height |
int |
600 |
Height in pixels |
render(shapes) - Render shapes, preserving camera position.
# Single shape
viewer.render(box)
# Multiple shapes
viewer.render([box, cylinder])
# Named parts with colors
viewer.render([
{"shape": base, "name": "Base", "color": "blue"},
{"shape": top, "name": "Top", "color": "red", "alpha": 0.8},
])
PartSpec
Dict for specifying parts with metadata:
| Key | Type | Required | Description |
|---|---|---|---|
shape |
Shape |
Yes | build123d object |
name |
str |
No | Display name |
color |
str |
No | Color name or hex |
alpha |
float |
No | Opacity 0.0-1.0 |
COLORS
Available named colors: blue, red, green, yellow, orange, purple, cyan, pink, gray, white, black
{"shape": box, "color": "blue"} # Named
{"shape": box, "color": "#ff6600"} # Hex
Export Functions
from marimo_cad import export_stl, export_step, export_gltf
export_stl(obj, "part.stl") # 3D printing
export_stl(obj, "fine.stl", tolerance=0.0001) # Higher resolution
export_step(obj, "part.step") # CAD interchange (lossless)
export_gltf(obj, "part.glb") # Web viewers
| Function | Parameters | Description |
|---|---|---|
export_stl |
obj, filename, tolerance=0.001, angular_tolerance=0.1 |
Tessellated mesh |
export_step |
obj, filename |
Exact geometry |
export_gltf |
obj, filename |
Web-ready format |
All return Path to exported file.
How It Works
- Tessellate: build123d → triangle meshes (ocp-tessellate)
- Transport: Mesh data → JavaScript (anywidget)
- Render: Three.js via three-cad-viewer
- Update:
render()updates geometry, camera preserved
License
MIT
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 marimo_cad-0.2.0.tar.gz.
File metadata
- Download URL: marimo_cad-0.2.0.tar.gz
- Upload date:
- Size: 942.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d84cbc8da1be9754522105ba8f76b9d00f64ec1e5536c2201ff7fa6a3f644f03
|
|
| MD5 |
4e28835ae6034065af8673f4f3c4daa9
|
|
| BLAKE2b-256 |
32e618e930aabaf7d11bc1db6760c12958067c04cbe898203f5e700a0a600ea7
|
Provenance
The following attestation bundles were made for marimo_cad-0.2.0.tar.gz:
Publisher:
publish.yml on cemrehancavdar/marimo-cad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marimo_cad-0.2.0.tar.gz -
Subject digest:
d84cbc8da1be9754522105ba8f76b9d00f64ec1e5536c2201ff7fa6a3f644f03 - Sigstore transparency entry: 954416471
- Sigstore integration time:
-
Permalink:
cemrehancavdar/marimo-cad@06d86ea3033e75ade5b391f672d1936ed2a3595d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/cemrehancavdar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06d86ea3033e75ade5b391f672d1936ed2a3595d -
Trigger Event:
release
-
Statement type:
File details
Details for the file marimo_cad-0.2.0-py3-none-any.whl.
File metadata
- Download URL: marimo_cad-0.2.0-py3-none-any.whl
- Upload date:
- Size: 383.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55e848a0fd0efe76fbf04cea188010299bca8cc3f927cf5a5b6fde9f0979afe4
|
|
| MD5 |
dda26208c73011c20bdda27334c56792
|
|
| BLAKE2b-256 |
d2afc6af633f818bb0476df5424157006ebdd8951680a1a8240f0fad9a9f1fab
|
Provenance
The following attestation bundles were made for marimo_cad-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on cemrehancavdar/marimo-cad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
marimo_cad-0.2.0-py3-none-any.whl -
Subject digest:
55e848a0fd0efe76fbf04cea188010299bca8cc3f927cf5a5b6fde9f0979afe4 - Sigstore transparency entry: 954416482
- Sigstore integration time:
-
Permalink:
cemrehancavdar/marimo-cad@06d86ea3033e75ade5b391f672d1936ed2a3595d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/cemrehancavdar
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@06d86ea3033e75ade5b391f672d1936ed2a3595d -
Trigger Event:
release
-
Statement type: