The config system¶
All four viewers share the same three-level configuration, with the same precedence. Only where the first level is stored differs per viewer.
- Viewer settings — the viewer's persistent configuration. In ocp_vscode these are the VS Code workspace settings, in ocp_viewer the
~/.ocpvscode_standalonefile and CLI flags, in Jupyter CadQuery and build123d Studio their own settings stores. See your viewer's documentation for where to edit them. set_defaults(...)— per Python process. Overrides the viewer settings for every subsequentshow*call in this process.- Keywords on
show/show_object/show_objects/show_all— per call. Override both levels below, for this call only.
Note that not all parameters are available in the viewer settings, since some don't make sense globally (e.g. helper_scale, which depends on the size of the bounding box of the currently shown object). For such keys, and for any key a viewer does not store, a built-in fallback sits underneath the three levels — timeit and debug off, show_locals on, helper_scale 1, collapse root and a few more — and it is only ever the answer when none of the three levels supplies the key.
There is a fourth participant that is not a level of its own: what you change in the running viewer — a toolbar toggle, a moved clipping slider — counts as viewer state and survives into the next show at the viewer-settings tier, so a toggle you clicked is not silently undone unless a set_defaults or a show keyword sets it explicitly. Inspect the effective result with combined_config() (see Viewer state below).
A common setup:
# %%
from build123d import *
import cadquery as cq
from ocp_viewer_core.viewer import *
set_defaults(reset_camera=Camera.CENTER, helper_scale=5)
# %%
...
- The first lines import build123d and CadQuery (omit what you are not interested in).
- The next line imports the complete viewer API, resolved to your viewer (see Importing).
set_defaultsthen setshelper_scaleandreset_cameraas defaults for every subsequentshow*call.
Defaults¶
-
set_defaults(**kwargs)Persist values across subsequent
show*calls in this Python process. Accepts the same viewer keywords asshow(see show.md). The viewer's settings provide the starting values;set_defaultsoverrides them. -
reset_defaults()Re-apply the viewer's settings on top of the running viewer and clear the in-process defaults set via
set_defaults. -
get_default(key)/get_defaults()Read a single default or the full merged default dict (built-in fallbacks, then viewer settings, then
set_defaults).
Viewer state¶
-
status(debug=False)Return the live state dict of the viewer (camera position, current tab, visibility states, …).
-
workspace_config()Return the viewer's configuration as the viewer currently sees it. Raises
RuntimeErrorif the viewer isn't reachable. -
combined_config()workspace_configmerged with the livestatusand anyset_defaultsoverrides — useful for "what will the nextshowactually use?" inspection.
The signatures show only the shared parameters; your viewer's variants additionally accept its addressing keyword — see "Addressing a viewer" in your viewer's chapter (VS Code CAD Viewer, OCP Viewer, Jupyter CadQuery).