Migration from 4.0¶
What a script written for OCP CAD Viewer 4.0 meets in 4.1. The full list of changes is in the changelog.
Autostart with ocp_viewer_core.viewer¶
The viewer starts automatically when an open Python file contains one of the lines in OcpCadViewer.advanced.autostartTriggers. 4.1 adds the two lines of the viewer-neutral import to that list, so a file that begins with
from ocp_viewer_core.viewer import *
starts the viewer like from ocp_vscode import * does. If you have changed autostartTriggers in your settings, your list replaces the default and does not gain the two new entries — add them yourself:
"OcpCadViewer.advanced.autostartTriggers": [
"from ocp_vscode import",
"import ocp_vscode",
"from ocp_viewer_core.viewer import",
"import ocp_viewer_core.viewer"
]
See Workspace Config and, for the import itself, Importing.
Changed behaviour¶
modifier_keysis one map per platform.OcpCadViewer.view.modifier_keysholds amacOSand adefaultmap (Windows and Linux); the extension applies the one for the platform it runs on, so a syncedsettings.jsonserves every machine. On Windows and Linux,metais the Alt key andaltthe Windows key by default. A flat map, the setting's previous shape, is still taken as it is. See Mouse and Keys.- Values are validated.
reset_camera,collapse,theme,up,orbit_controland the other enumerated keys are checked whenshow(),set_defaults()orset_viewer_config()is called — a typo raises instead of vanishing. Keywords that belong to another viewer (viewer,anchor,pinning,cad_width,height) are refused with a message. set_viewer_config()applies thestudio_*keys, which the viewer used to drop, andmodifier_keyscan be set at runtime.ocp_vscodedepends onocp-viewer-coreonly.ocp_tessellate,websockets,questionary,pillowandthreejs-materialscome with the core;flask,flask_sock,click,pyperclip,pyaml,requestsandpygltflibare no longer installed. The Library Manager listsocp_viewer_coreso the core can be upgraded from the sidebar.- The extension and
ocp_vscodemust agree on major.minor; a patch-level difference is accepted. The viewer page checks the core's JavaScript against the core's Python on every show and reports a mismatch to the developer console. -
from ocp_vscode import *still works. For code that runs unchanged under every viewer of the family, import fromocp_viewer_core.viewerinstead — it picks the viewer of the environment it runs in (see the autostart note above):from ocp_viewer_core.viewer import *
Removed and deprecated¶
OcpCadViewer.view.darkis gone; it had been deprecated in favour ofOcpCadViewer.view.theme. A settings file still carryingdarkgets the theme default (browser).controlandmate_scaleare gone; useorbit_controlandhelper_scale. Both had been deprecated.up="L"is no longer accepted;upis"Z"or"Y".reset_camera=True/False,collapse="C"/"1"/"R"/"E",render_edgesandshow_sketch_localstill work but warn; useCamera.RESET/Camera.CENTER, theCollapseenum,modesandshow_locals.- The standalone viewer (
python -m ocp_vscodewithout--backend) is the separate OCP Viewer package now; running the module without arguments says so.