A simple interactive 3D viewer for CadQuery models using Plotly
Project description
cadquery-simpleViewer
An interactive 3D viewer for CadQuery models, built on Plotly. Renders geometry directly inside Jupyter notebooks and Google Colab cells — no external software, no extensions, no server required.
Features
- Interactive orbit, zoom and pan inside the notebook cell
- Axes visibility toggles (X, Y, Z independently)
- Camera mode selector (Perspective / Orthographic)
- Optional ground plane at a chosen elevation
- Equal scale enforced across all three axes — 1 unit in X occupies the same screen distance as 1 unit in Y or Z
- Works in JupyterLab, VS Code notebooks, and Google Colab
Installation
pip
pip install cadquery-simpleviewer
uv
uv add cadquery-simpleviewer
pixi (PyPI source)
pixi add --pypi cadquery-simpleviewer
Poetry
poetry add cadquery-simpleviewer
Note:
cadquery-simpleviewerdeclaresplotlyas a dependency but intentionally does not pincadqueryitself — users typically manage their CadQuery installation separately (pip, conda, or thecadqueryconda channel via pixi). See the CadQuery installation guide for details.
Quick Start
import cadquery as cq
from cadquery_simpleviewer import show
box = cq.Workplane("XY").box(5, 3, 2)
show(box)
Multiple objects with names and colors
box = cq.Workplane("XY").box(5, 3, 2)
cylinder = cq.Workplane("XY").cylinder(6, 1).translate((8, 0, 0))
show(
[box, cylinder],
names=["Box", "Cylinder"],
colors=["lightsteelblue", "indianred"]
)
With a ground plane
show(
[box, cylinder],
names=["Box", "Cylinder"],
z=0,
plane_color="gainsboro",
plane_size=20
)
Clean architectural presentation (axes hidden)
show(
[box, cylinder],
names=["Box", "Cylinder"],
visible_axes=None,
z=0,
plane_color="whitesmoke",
plane_size=20
)
Google Colab
Install at the top of the notebook, then use normally:
!pip install cadquery cadquery-simpleviewer
import cadquery as cq
from cadquery_simpleviewer import show
box = cq.Workplane("XY").box(5, 3, 2)
show(box)
The viewer renders inline as an interactive Plotly figure. No extensions or widget managers are needed.
show() Reference
show(
objects,
names=None,
colors=None,
opacity=1.0,
visible_axes="xyz",
z=None,
plane_color="whitesmoke",
plane_size=50,
plane_opacity=0.8,
tessellation_tolerance=0.01,
padding=0.15,
)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
objects |
object or list | — | Single CadQuery Workplane object or a list of them |
names |
list of str | None |
Legend label for each object. Defaults to "Object 1", "Object 2", … |
colors |
list of str | None |
Face color for each object. Accepts CSS color names and hex values. See Plotly CSS colors for the full list. Defaults to a built-in palette |
opacity |
float | 1.0 |
Surface opacity applied to all objects. 1.0 = fully opaque, 0.0 = fully transparent |
visible_axes |
str or None | "xyz" |
Initial axes visibility. None hides all axes. Any combination of "x", "y", "z" shows only those axes. Valid values: None, "x", "y", "z", "xy", "xz", "yz", "xyz" |
z |
float or None | None |
Elevation of the ground plane. When None no plane is drawn |
plane_color |
str | "whitesmoke" |
Color of the ground plane |
plane_size |
float | 50 |
Half-side length of the ground plane quad. The plane extends ±plane_size from the scene center in X and Y |
plane_opacity |
float | 0.8 |
Opacity of the ground plane |
tessellation_tolerance |
float | 0.01 |
Mesh precision used when converting the BREP solid to triangles. Smaller values produce a finer mesh but are slower |
padding |
float | 0.15 |
Fraction of the bounding box span added as margin on each axis. 0.15 = 15% padding on each side |
Interactive controls
Once rendered, the figure provides:
| Control | Action |
|---|---|
| X ● / X ○ | Toggle X axis on or off |
| Y ● / Y ○ | Toggle Y axis on or off |
| Z ● / Z ○ | Toggle Z axis on or off |
| Camera | Switch between Perspective and Orthographic projection |
| Left drag | Orbit |
| Scroll | Zoom |
| Right drag | Pan |
Pixi environment example
A minimal pixi.toml for a CadQuery project using this viewer:
[workspace]
channels = ["cadquery", "conda-forge"]
name = "my_project"
platforms = ["win-64", "osx-arm64", "osx-64", "linux-64"]
[dependencies]
python = "3.12.*"
cadquery = "*"
ipykernel = ">=6"
[pypi-dependencies]
cadquery-simpleviewer = "*"
Repository
https://github.com/255ribeiro/cadquery-simpleViewer
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 cadquery_simpleviewer-0.1.9.tar.gz.
File metadata
- Download URL: cadquery_simpleviewer-0.1.9.tar.gz
- Upload date:
- Size: 148.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c86f0c30da3b13ac0e80e14fb9ce1ebbf08cbb3e1ed2caa70958448fb75e6a0
|
|
| MD5 |
e152fc39ccedae1a290f472358bf49a7
|
|
| BLAKE2b-256 |
aa310ec5a92eccdbb4127dfd2d47700f849c0adb262119112c70eb6d7c3cd128
|
File details
Details for the file cadquery_simpleviewer-0.1.9-py3-none-any.whl.
File metadata
- Download URL: cadquery_simpleviewer-0.1.9-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.4.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0346d2b811a9779d80ef1beb6df7c71b01e1609259264918122b3417c09d681
|
|
| MD5 |
34f55a8b61216d85bb57462246aa9eba
|
|
| BLAKE2b-256 |
eac04ad9eb2fb1e79ac2fd22c3f1c03cf0ceb6cb28fe6c4afc735b2bc3e49003
|