Skip to main content

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-simpleviewer declares plotly as a dependency but intentionally does not pin cadquery itself — users typically manage their CadQuery installation separately (pip, conda, or the cadquery conda 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


Download files

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

Source Distribution

cadquery_simpleviewer-0.2.0.tar.gz (147.7 kB view details)

Uploaded Source

Built Distribution

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

cadquery_simpleviewer-0.2.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file cadquery_simpleviewer-0.2.0.tar.gz.

File metadata

File hashes

Hashes for cadquery_simpleviewer-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e5c454be059bfeffa362404595c8692764b27ffa49777fd5c21f932a15b5bbcc
MD5 cfe9f894556ffb78dccca8d282854e02
BLAKE2b-256 145097f959c6cf52f4bb8b9892a918e6bddcfe99ffc5232de22dd259e15104b6

See more details on using hashes here.

File details

Details for the file cadquery_simpleviewer-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cadquery_simpleviewer-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf9f6ab5cb19d46aaf8ff17065968fd4feb094a20d8e51cfc9dc0f6517f644b5
MD5 1436e2b9954d2b072e8f1a362fdaac38
BLAKE2b-256 d16cdc0a9a199208277f818e2c2f7b75d56d8f192822a2c98554e543f89d7a4a

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