ocp-viewer-cadinterface
A plugin for the OCP viewers (OCP CAD Viewer for VS Code,
OCP Viewer, Jupyter CadQuery, build123d Studio). With it, show and show_all display any
object that implements the __cad_interface__
protocol, and the viewer's measurement tools work on it, including between it and build123d
or CadQuery objects in the same scene.
import build123d as bd
import solidfunc as sf # a CAD library on a non-OCCT kernel
from ocp_vscode import show
plate = sf.box(size_x=80, size_y=50, size_z=10) - sf.cylinder(diameter=20, height=10)
cube = bd.Pos(65, 0, 5) * bd.Box(10, 10, 10)
show(plate, cube, names=["plate", "cube"]) # measure the 20 mm between them in the viewer
examples/demo.ipynb has the full example.
Install
pip install ocp-viewer-cadinterface
Install it in the environment your script runs in. Your script does not import it: the viewer
finds it through its entry point at the first show. A Jupyter kernel that has already shown
something needs a restart after the install.
The measurement backend's environment needs nothing extra, because the plugin hands only OCCT shapes to the viewer (see below).
It needs ocp-tessellate 3.7 and, for the viewer, ocp-viewer-core 1.2 or later.
What it shows
- A
ShapeDictin any version 1 format:"ocp","brep_binary","brep_text","step". The plugin asks for them in that order."ocp"shapes are used as they are, without a copy. - An
AssemblyDict: a tree of groups, with the nodes' names, locations and colours. A node without a colour takes its parent's. Geometry used by several nodes is read and meshed once. - Solids, shells, faces, wires, edges, vertices and compounds of them, including compounds that mix several kinds.
Names, colours and alphas passed to show take precedence over the producer's, as the protocol
asks consumers to do. An unnamed shape is named by its type, as an OCCT shape is.
build123d and CadQuery objects, and objects of your own subclasses of their classes, are never taken by this plugin, even once they implement the protocol. The viewer draws them itself, with more information (joints, parents, materials).
How it works
Every result becomes OCCT shapes, read with the OCCT binding ocp-tessellate runs on. From there
the shapes take the viewer's OCCT path: OCCT tessellates them, and the measurement backend
measures them as OCCT shapes. So the plugin has only the drawing half of a
kernel plugin, one module
registered through the entry point group ocp_viewer.kernels.show, and no tessellation and no
backend of its own.
Each show calls __cad_interface__ once per object, so a changed object is shown as it is now. What
was read is cached by its content, so the same STEP data is parsed once (a STEP header's time
stamp is ignored), and OCCT reuses its mesh.
Limits
- The viewer shows and measures OCCT's reading of the producer's data (for solidfunc, of its STEP output), not the producer's kernel's own geometry. Showing a kernel's own geometry needs a kernel plugin. The two complement each other: the protocol makes any library visible with one method, and a kernel plugin makes one kernel first-class.
- Faces and edges can only be shown on their own if the producer implements the protocol on them. A face picked in the viewer does not map back to the producer's face: names of sub-shapes are not part of version 1 of the protocol.
- Kernel plugins are asked in no defined order. If a kernel with its own plugin also implemented the protocol, both plugins would claim its objects.
Development
python -m venv .venv && . .venv/bin/activate
pip install -e ".[test]"
pytest
ruff check . && ruff format --check .
The tests use producers written by hand with plain OCP, one per format, plus solidfunc and build123d parts measured against each other through ocp-viewer-core's backend.
Licence
MIT
Metadata
Release files for ocp-viewer-cadinterface 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ocp_viewer_cadinterface-0.1.0.tar.gz | 17.6 kB | With provenance | Details for ocp_viewer_cadinterface-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ocp_viewer_cadinterface-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ocp_viewer_cadinterface-0.1.0-py3-none-any.whl |
Total release size: 29.0 kB
Release files / ocp_viewer_cadinterface-0.1.0.tar.gz
| Download URL | ocp_viewer_cadinterface-0.1.0.tar.gz |
|---|---|
| Size | 17.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
465baefc1d05baf597d70773e3f91fbd714136fad8ae2e6afd76a03b0a9ef18e
|
|
BLAKE2b-256 checksum How to use checksums |
5ba8dff3104515cb5591d161452ea0051fb4ef3d401a3e9a37228b68c5fa5e8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / ocp_viewer_cadinterface-0.1.0-py3-none-any.whl
| Download URL | ocp_viewer_cadinterface-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d8c1aa6e7ed9a100a2fb3ae276a9d08a8ab04cbaf0adb9f67fdfb6af4848a51a
|
|
BLAKE2b-256 checksum How to use checksums |
501f1956d354ce75a49975ebf42caeeab6d418ac4398735dfed8df4f55193b05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for ocp-viewer-cadinterface 0.1.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ocp_viewer_cadinterface-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA 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.