Skip to content

The OCP CAD viewer documentation

There are four viewers in the OCP Viewer ecosystem:

VS Code CAD Viewer | OCP Viewer
Jupyter Cadquery | Build123d Studio

They are all built on ocp-viewer-core, and share the same show commands, the same configuration semantics and the same viewer window, see Architecture. What differs per viewer is only how it is installed and started, where its settings are stored, and how Python reaches it.

This documentation first introduces the four viewers in Viewers: how they are installed, how to run code, where settings are stored, and their viewer-specific features.

The chapters CAD Viewer and The Python API then document the shared part, valid for every viewer.

The underlying concepts, e.g. how the pieces fit together, are explained in the Concepts chapter.

Viewers

One chapter per viewer for what genuinely differs: installation, settings storage, port discovery and set_port, sidecars, visual debugging integrations, editor tooling, troubleshooting.

The CAD Viewer

  • Overview — the window's layout, the toolbar, the info box, and what the viewer remembers. This is the JavaScript half of the core, embedded by every viewer.
  • Mouse and Keys — navigation and selection bindings, and remapping the modifier keys
  • Tabs — the tree panel's five tabs: Tree, Clip, Zebra, Material, Studio
  • Analysis tools:
    • Overview — picking and filters, programmatic activation, mesh-based vs CAD-exact numbers
    • Measure mode — the Distance and Properties tools and their panels
    • Object selection — pick faces, edges or vertices and use their indices in code
  • Dynamic features — explode and the animation bar

The Python API

  • Importing — one vocabulary, two import styles: your viewer's own package, or the portable ocp_viewer_core.viewer

Showing objects:

  • show — show one or more CAD objects, and the full keyword reference shared by all show commands
  • show_object — show objects incrementally, one call per object
  • push_object / show_objects — collect objects without rendering, then render them in one batch
  • show_all — show every CAD object in the current Python scope
  • Keeping the camera orientation — the reset_camera semantics: keep, recenter, reset, or snap to a preset
  • Additional functionsshow_clear, save_screenshot, and blueprint images

Configuring:

  • The config system — the three levels of configuration and their precedence, and the defaults and state inspection functions
  • set_viewer_config — change a running viewer immediately, without a new show
  • EnumsCamera, Collapse, Render, AnalysisTool, UiTab and the Studio enums

Appearance:

Animation:

  • Animation — drive keyframe animations on shown assemblies

Concepts

Versions

This documentation describes the following versions — patch releases within each line stay covered:

Component Documented version
ocp-viewer-core 1.0.x
OCP CAD Viewer for VS Code (ocp_vscode) 4.1.x
OCP Viewer (ocp_viewer) 1.1.x
Jupyter CadQuery (jupyter_cadquery) 5.1.x
cad-viewer-widget 4.1.x
build123d Studio 0.6.x
three-cad-viewer 5.0.x
ocp-tessellate 3.5.x