Skip to main content

ocp_viewer

The standalone OCP CAD viewer: a browser page and the server behind it.

Installation

pip install ocp_viewer

into the environment that also holds your CAD library (build123d or cadquery).

From a checkout — for local use with uv add path/to/ocp-viewer, uv pip install path/to/ocp-viewer or pip install path/to/ocp-viewer — run make assets in the checkout first. The page's JavaScript and stylesheet are copied in from npm and are not in git, so a package built from a checkout that never ran it ships without them; the server says so at start. make dist runs it for you.

Run

python -m ocp_viewer

and open the printed URL in a browser — http://127.0.0.1:3939 by default. Then show from any Python process in that environment:

from build123d import *
from ocp_viewer import *

show(Box(1, 2, 3))

— the same show you would use with the VS Code extension, pointed at this viewer.

Documentation

Everything else — settings, addressing several viewers, editors, Docker, the whole shared behavior — is in the documentation: the OCP Viewer chapter for this viewer's specifics, bernhard-42.github.io/ocp_viewer_docs for the rest.

What is here, and what is not

Almost nothing about viewing is here. The show pipeline, the config semantics, the render and camera policy, the tree state, the measurement backend, the splash logo, the port registry and the wire protocol are all ocp-viewer-core, shared with the VS Code extension, Jupyter CadQuery and build123d Studio. What is left is a websocket server that also hands out one page, and the settings that reach them.

That is the point of the split rather than a side effect of it. A camera that behaves differently here than in VS Code is a bug in one of them, and there is now one place to fix it.

file what
server/__init__.py serve — the websocket server, for the command line
__main__.py the CLI; every option is a viewer setting
server/settings.py defaults, the config file, and the command line on top of both
server/viewer.py what a running viewer knows: its two clients, its config, its state
server/pages.py the page, the files it loads, and a redirect to it
server/sockets.py the one websocket, and the six kinds of message on it
comms.py this host's transport: the core's websocket client, pointed at a viewer
server/network.py is something already listening on that port

Settings

Three sources, later winning over earlier:

  1. the defaults in server/settings.py
  2. ~/.ocpvscode_standalone, if it exists — write one with python -m ocp_viewer --create_configfile
  3. the command line — python -m ocp_viewer --help

The file keeps its old name so that an existing one still works.

Development

make install      # editable
make assets       # copy the renderer and the core into static/
make check        # ruff check + ty check, and no formatter
make run

make assets copies JavaScript out of node_modules: three-cad-viewer and ocp-viewer-core are npm packages, installed from the registry. The copies under static/ are gitignored. After bumping either dependency, run make assets again so they follow.

Licence

Apache-2.0.

Metadata

Release files for ocp-viewer 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ocp-viewer 1.3.0
File Size Uploaded Provenance Actions
ocp_viewer-1.3.0.tar.gz 1.0 MB Without provenance Details for ocp_viewer-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ocp-viewer 1.3.0
File Interpreter ABI Platform Actions
ocp_viewer-1.3.0-py3-none-any.whl Python 3 none any Details for ocp_viewer-1.3.0-py3-none-any.whl

Total release size: 2.1 MB

Release files / ocp_viewer-1.3.0.tar.gz

Download URL ocp_viewer-1.3.0.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
c57d4d531059d63f774d6d703e1f7d96edb07ad59cc28116eabb772af2cc67a9
BLAKE2b-256 checksum
How to use checksums
85e391150c9c4c72a96b9a5eae31cf3cae85c7de28cebc61ef9fa31f4b151e8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Release files / ocp_viewer-1.3.0-py3-none-any.whl

Download URL ocp_viewer-1.3.0-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9a6ce83b399e5e2b6488b933272601feb60a2e7d8804ecffcb8c22008b26cfd6
BLAKE2b-256 checksum
How to use checksums
7951a93bd4adda2bf83302dbae9fb3cb19142585701fe1cd0438339ed0efce5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.9

Security for ocp-viewer 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page