# _OCP CAD Viewer_ for VS Code
_OCP CAD Viewer_ for VS Code is an extension to show [CadQuery](https://github.com/cadquery/cadquery) and [build123d](https://github.com/gumyr/build123d) objects in VS Code via the [three-cad-viewer](https://github.com/bernhard-42/three-cad-viewer) viewer component.
## Installation
### Prerequisites
- A fairly recent version of Microsoft VS Code, e.g. 1.85.0 or newer
- The [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) installed in VS Code
- Necessary tools:
- `python` and `pip` available in the Python environment that will be used for CAD development. Note, even when you use another package manager, `pip ` is needed internally and needs to be available.
**Notes**:
- To use OCP CAD Viewer, start VS Code from the commandline in the Python environment you want to use or select the right Python interpreter in VS Code first. **OCP CAD Viewer depends on VS Code using the right Python interpreter** (i.e. mamba / conda / pyenv / poetry / ... environment).
- For VSCodium, the extension is not available in the VS code market place. You need to download the the vsix file from the [release folder](https://github.com/bernhard-42/vscode-ocp-cad-viewer/releases) and install it manually.
### Installation
1. Open the VS Code Marketplace, and search and install _OCP CAD Viewer 2.8.9_.
Afterwards the OCP viewer is available in the VS Code sidebar:

2. Clicking on it shows the OCP CAD Viewer UI with the viewer manager and the library manager:

You have 3 options:
- Prepare _OCP CAD Viewer_ for working with [build123d](https://github.com/gumyr/build123d): Press the _Quickstart build123d_ button.
This will install _OCP_, _build123d_, _ipykernel_ (_jupyter_client_), _ocp_tessellate_ and _ocp_vscode_ via `pip`

- Prepare _OCP CAD Viewer_ for working with [CadQuery](https://github.com/cadquery/cadquery): Press the _Quickstart CadQuery_ button.
This will install _OCP_, _CadQuery_, _ipykernel_ (_jupyter_client_), _ocp_tessellate_ and _ocp_vscode_ via `pip`

- Ignore the quick starts and use the "Library Manager" to install the libraries via `pip` (per default, this can be changed in the VS Code settings). Install the needed library by pressing the down-arrow behind the library name (hover over the library name to see the button) in the "Library Manager" section of the _OCP CAD Viewer_ sidebar. For more details, see [here](./docs/install.md)
Quickstart will also
- (optionally) install the the [Jupyter extension for VS Code from Microsoft](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter)
- start the OCP viewer
- create a demo file in a temporary folder to quickly see a simple usage example
**Notes:**
- Do not use the _OCP CAD Viewer_ logo to verify your _OCP CAD Viewer_ settings! The logo overwrites all your settings in VS Code with its own settings to always look the same on each instance. Use a simple own model for checking your configuration
- If you run into issues, see [Troubleshooting](#troubleshooting)
## Usage
### Running code using Jupyter
- Start the _OCP CAD Viewer_ by pressing the box-arrow button in the "Viewer Manager" section of the _OCP CAD Viewer_ sidebar (hover over the `ocp_vscode` entry to see the button).
- Import ocp_vscode and the CAD library by using the paste button being the library names in the "Viewer Manager" section
- Use the usual Run menu to run the code

### Debugging code with visual debugging
After each step, the debugger checks all variables in `locals()` for being CAD objects and displays them with their variable name.
Note:
- Check that `OCP:on` is visible in the status bar
- It also shows planes, locations and axis, so name your contexts
- It remembers camera position and unselected variables in the tree
- during debugging, `show` and `show_object` are disabled. They interfere with the visual debugging

### Library Manager
You can also use "Library Manager" in the _OCP CAD Viewer_ sidebar to manage the Python libraries for _build123d_, _cadquery_, _ipython_ and _ocp_tessellate_ (Press the down-arrow when hovering over a library name to install/upgrade it)
### Extra topics
- [Quickstart experience on Windows](docs/quickstart.md)
- [Use Jupyter to execute code](docs/run.md)
- [Debug code with visual debugging](docs/debug.md)
- [Measure mode](docs/measure.md)
- [Object selection mode](docs/selector.md)
- [Use the `show` command](docs/show.md)
- [Use the `show_object` command](docs/show_object.md)
- [Use the `push_object` and `show_objects` command](docs/push_object.md)
- [Use the `show_all` command](docs/show_all.md)
- [Use the `set_viewer_config` command](docs/set_viewer_config.md)
- [Download examples for build123d or cadquery](docs/examples.md)
- [Use the build123d snippets](docs/snippets.md)
## Standalone mode
Standalone mode allows to use OCP CAD Viewer without VS Code: `python -m ocp_vscode`. This will start a Flask server and the viewer can be reached under `http://127.0.0.1/viewer`. All client side feature of the VS Code variant (i.e. `show*` features) should be available (including measurement mode) except visual debugging (see above) which relies on VS Code.
Use `python -m ocp_vscode --help` to understand the command line args:
```
Usage: python -m ocp_vscode [OPTIONS]
Options:
--create_configfile Create the config file .ocpvscode_standalone in
the home directory
--host TEXT The host to start OCP CAD with
--port INTEGER The port to start OCP CAD with
--debug Show debugging information
--timeit Show timing information
--tree_width TEXT OCP CAD Viewer navigation tree width
(default: 240)
--no_glass Do not use glass mode with transparent
navigation tree
--theme TEXT Use theme 'light' or 'dark' (default:
'light')
--no_tools Do not show toolbar
--tree_width INTEGER Width of the CAD navigation tree (default:
240)
--control TEXT Use control mode 'orbit'or 'trackball'
--up TEXT Provides up direction, 'Z', 'Y' or 'L'
(legacy) (default: Z)
--rotate_speed INTEGER Rotation speed (default: 1)
--zoom_speed INTEGER Zoom speed (default: 1)
--pan_speed INTEGER Pan speed (default: 1)
--axes Show axes
--axes0 Show axes at the origin (0, 0, 0)
--black_edges Show edges in black
--grid_xy Show grid on XY plane
--grid_yz Show grid on YZ plane
--grid_xz Show grid on XZ plane
--center_grid Show grid planes crossing at center of object
or global origin(default: False)
--collapse INTEGER leaves: collapse all leaf nodes, all:
collapse all nodes, none: expand all nodes,
root: expand root only (default: leaves)
--perspective Use perspective camera
--ticks INTEGER Default number of ticks (default: 10)
--transparent Show objects transparent
--default_opacity FLOAT Default opacity for transparent objects
(default: 0.5)
--explode Turn explode mode on
--angular_tolerance FLOAT Angular tolerance for tessellation algorithm
(default: 0.2)
--deviation FLOAT Deviation of for tessellation algorithm
(default: 0.1)
--default_color TEXT Default shape color, CSS3 color names are
allowed (default: #e8b024)
--default_edgecolor TEXT Default color of the edges of shapes, CSS3
color names are allowed (default: #707070)
--default_thickedgecolor TEXT Default color of lines, CSS3 color names are
allowed (default: MediumOrchid)
--default_facecolor TEXT Default color of faces, CSS3 color names are
allowed (default: Violet)
--default_vertexcolor TEXT Default color of vertices, CSS3 color names
are allowed (default: MediumOrchid)
--ambient_intensity INTEGER Intensity of ambient light (default: 1.00)
--direct_intensity FLOAT Intensity of direct light (default: 1.10)
--metalness FLOAT Metalness property of material (default:
0.30)
--roughness FLOAT Roughness property of material (default:
0.65)
--help Show this message and exit.
```
## Standalone mode with Docker
If you are not using vscode and you prefer to keep the standalone web viewer running separated in a container,
then take a look at [docker-vscode-ocp-cad-viewer](https://github.com/nilcons/docker-vscode-ocp-cad-viewer).
## Best practices
- Use the **Jupyter extension** for a more interactive experience. This allows to have one cell (separated by `# %%`) at the beginning to import all libraries
```python
# %%
from build123d import *
from ocp_vscode import *
# %%
b = Box(1,2,3)
show(b)
# %%
```
and then only execute the code in the cell you are currently working on repeatedly.
- The **config system** of OCP CAD Viewer
There are 3 levels:
- Workspace configuration (part of the VS Code settings, you can access them e.g. via the gear symbol in OCP CAD Viewer's "Viewer Manager" when you hover over the label "VIEWER MANAGER" to see the button)
- Defaults set with the command `set_defaults` per Python file
- Parameters in `show` or `show_object` per command
`set_defaults` overrides the Workspace settings and parameters in `show` and `show_config` override the other two.
Note that not all parameters are available in the global Workspace config, since they don't make sense globally (e.g. `helper_scale` which depends on the size of the boundary box of the currently shown object)
A common setup would be
```python
# %%
from build123d import *
import cadquery as cq
from ocp_vscode import *
set_port(3939)
set_defaults(reset_camera=False, helper_scale=5)
# %%
...
```
Explanation
- The first block imports build123d and CadQuery (omit what you are not interested in).
- The second block imports all commands for OCP CAD Viewer. `set_port` is only needed when you have more than one viewer open and can be omitted for the first viewer)
- The third block as an example sets helper_scale and reset_camera as defaults. Then every show_object or show command will respect it as the default
- Debugging build123d with `show_all` and the **visual debugger**
- If you name your contexts (including `Location` contexts), the visual debugger will show the CAD objects assigned to the context.
- Use `show_all` to show all cad objects in the current scope (`locals()`) of the Python interpreter (btw. the visual debugger uses `show_all` at each step)
```python
# %%
from build123d import *
set_defaults(helper_scale=1, transparent=True)
with BuildPart() as bp:
with PolarLocations(3,8) as locs:
Box(1,1,1)
show_all()
# %%
```

- **Keep camera orientation** of an object with `reset_camera`
Sometimes it is helpful to keep the orientation of an object across code changes. This is what `reset_camera` does:
- `reset_camera=Camera.Center` will keep position and rotation, but ignore panning. This means the new object will be repositioned to the center (most robust approach)
- `reset_camera=Camera.KEEP` will keep position, rotation and panning. However, panning can be problematic. When the next object to be shown is much larger or smaller and the object before was panned, it can happen that nothing is visible (the new object at the pan location is outside of the viewer frustum). OCP CAD Viewer checks whether the bounding box of an object is 2x smaller or larger than the one of the last shown object. If so, it falls back to `Camera.CENTER`. A notification is written to the OCP CAD Viewer output panel.
- `reset_camera=Camera.RESET` will ensure that position, rotation and panning will be reset to the initial default
## Development
Testing:
Native tessellator can be set via `NATIVE_TESSELLATOR=1` and Python tessellator via `NATIVE_TESSELLATOR=0`.
When `OCP_VSCODE_PYTEST=1` is set, `show` will not send the tessellated results to the viewer, but return it to the caller for inspection.
A full test cycle consist of:
```bash
NATIVE_TESSELLATOR=0 OCP_VSCODE_PYTEST=1 pytest -v -s pytests/
NATIVE_TESSELLATOR=1 OCP_VSCODE_PYTEST=1 pytest -v -s pytests/
```
## Troubleshooting
- **Generic ("it doesn't work")**
1) Confirm that VS Code extension and ocp_vscode have the same version. This can be seen in the OCP CAD Viewer UI. Or alternatively in the Output panel of VS Code:
```text
2025-07-06 14:51:33.418 [info ] extension.check_upgrade: ocp_vscode library version 2.8.6 matches extension version 2.8.6
```
2) Test whether the standalone viewer works, see [Standalone mode](#standalone-mode) (to eliminate VS Code issues)
3) Open a work folder and not a Python file (to ensure we do not get in Python path problems)
4) Check the Output panel. Search for:
- `PythonPath: 'aaa/bbb/python'` **=> right Python environment?**
- `Server started on port xxxx` (or so) **=> right port? default is 3939**
- `Starting Websocket server` **=> should not be followed by an error**
- `OCP Cad Viewer port: xxxx, folder: yyyy zzzz` **=> yyyy should be the right working folder?**
5) If all looks fine until now, then toggle Developer tools in VS Code and check browser console. Often we see a WebGL error for the browser of VS Code used for the viewer.
- **CAD Models almost always are invisible in the OCP viewer window**
```bash
three-cad-viewer.esm.js:20276 THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false
Material Name:
Material Type: LineBasicMaterial
Program Info Log: Program binary could not be loaded. Binary is not compatible with current driver/hardware combination. Driver build date Mar 19 2024. Please check build information of source that generated the binary.
Location of variable pc_fragColor conflicts with another variable.
```
VS Code internal browser that renders the viewer component uses a cache for code and other artifacts. This includes WebGL artifacts like compiled shaders. It can happen that e.g. due to a graphic driver update the compiled version in the cache does not fit to the new driver. Then this error message appears.
**Solution:** [Delete the VS Code browser cache on Linux](https://bobbyhadz.com/blog/vscode-clear-cache) (go to the section for your operating system)
## Changes
### v2.8.9
**Fixes**
- Add a robuts port in use detection to Windows
### v2.8.8
**Fixes**
- Fix regression of wrong level for continue statement leading to show_all crashing
### v2.8.7
**Fixes**
- Startup now checks all visible python files for trigger statements. If any has, autostart kicks in.
- More than two Viewer columns are supported
- Fixed a bug where an empty `~/.ocpvscode` file crashed `show` [#183](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/183)
- Fixed calling jupyter console
- Moved all `show_all` warnings behind `debug=True` parameter
### v2.8.6
**Features**
- Fixed blank viewer issue by resolving a race condition properly ([#171](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/171))
- Made statements that trigger OCP CAD Viewer to start editable in settings (`Ocp Cad Viewer > Advanced : Autostart Triggers`). They now default to `import ocp_vscode` and `from ocp_vscode import` and don't include "build123d" and "cadquery" any more
- Set backend precision to 3 ([#179](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/179))
- Clicking on a tree label with shift+meta hides all others without change of location ([#178](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/178))
- Hid the `show_all` warnings about non viewable types. Can still be seen with the `debug` parameter
- Added a button to the quickstart welcome screen to change the environment
**Fixes**
- Fix broken check for ocp_vscode when it is installed in user site-packages ([#181](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/181))
- Ensured to refresh library and viewer manager at VS Code start, even when build123d is not imported ([#177](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/177))
- Fix broken helix discretizing ([#176](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/176))
- Ensure that lines and arrows for measurements are initialized once only to remove memory leaks ([#29](https://github.com/bernhard-42/three-cad-viewer/issues/29))
- Disable text selection of UI elements except info box
- Fix isolate mode when there are only 1-dim objects in the viewer ([#178](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/178))
- Keep camera position when "Isolate element" action is taken ([#174](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/174))
### v2.8.5
**Fixes**
- Clean up viewerStarting flag in error case
- Fix broken handling of mirrored curve in ocp-tessellate ([#170](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/170))
- Remove deviding line deflection by 100 ([#172](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/172))
### v2.8.4
**Fixes**
- Add handling of view log mesage forwarding to standalone mode
### v2.8.3
**Fixes**
- Fix dual stack port detection on Linux ([#171](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/171))
- Close old viewer window if exists on viewer start
### v2.8.2
**Features**
- Add clear and update params to push_object
- Add removal and update of an individual part in show_object
- Introduce shortcuts select_face, select_edge, select_vertex for the selection mode
**Fixes**
- Rewrite port check and add more debug info
- Ensure to wait for all async functions at startup
- Fix grid_xz / grid_yz mix-up in standalone mode
- Improve logging during viewer start
### v2.8.1
***Fixes**
- Fixed typos in doc strings and everywhere else
- Fixed a f-string issue with broken quotes
- Enhanced port running check to tcp4 and tcp6
- Documented visual debugging with pdb ([#164](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/164))
### v2.8.0
**Features**
- Add a color marker behind the node name of the navigation tree showing the object color
- New "select objects" mode that allows to retrieve stable object indices that can be used in python code to select objects
- Removed the need of an open workspace. If the extension cannot identify a Python environment with ocp_vscode, it asks for it. ([#160](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/160), [#163](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/163))
- Simplified port detection. Every viewer stores its port into `~/.ocpvscode`. If mode than one active port is detected, show let's you select the right one ([#163](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/163))
- Improve startup reliability and performance
- Allow setting port in launch.json
- Add `include` argument to `show_all`
- Add `push_object` and `show_objects` to control showing objects in a lazy manner
- Bump to three-cad-viewer 3.4.0
**Fixes**
- Clean up startup sequence and fix start issues with Jupyter interactive window
- Fix disposing all viewer objects on closing the viewer
- Ensure revive of viewer is not used in autostart mode
- Improve pip list parsing
- Start backend with a temp folder instead of work directory
- Fix naming `vertex0` to `vertex_0` (and so on) in exploded mode (three-cad-viewer)
- Fix clear and dispose behavior (three-cad-viewer [#27](https://github.com/bernhard-42/three-cad-viewer/issues/27))
- Fix `save_screenshot` throwing an error ([#162](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/162))
Raw data
{
"_id": null,
"home_page": null,
"name": "ocp-vscode",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "3d models, 3d printing, 3d viewing, 3d, brep, cad, cadquery, opencscade, python",
"author": null,
"author_email": "Bernhard Walter <b_walter@arcor.de>",
"download_url": "https://files.pythonhosted.org/packages/3a/85/2cb9b654b6e469cd6e7a642d2a5273ce1da3d3a109a1d41e8ed28bb49cf3/ocp_vscode-2.8.9.tar.gz",
"platform": null,
"description": "# _OCP CAD Viewer_ for VS Code\n\n_OCP CAD Viewer_ for VS Code is an extension to show [CadQuery](https://github.com/cadquery/cadquery) and [build123d](https://github.com/gumyr/build123d) objects in VS Code via the [three-cad-viewer](https://github.com/bernhard-42/three-cad-viewer) viewer component.\n\n## Installation\n\n### Prerequisites\n\n- A fairly recent version of Microsoft VS Code, e.g. 1.85.0 or newer\n- The [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) installed in VS Code\n- Necessary tools:\n - `python` and `pip` available in the Python environment that will be used for CAD development. Note, even when you use another package manager, `pip ` is needed internally and needs to be available.\n\n**Notes**:\n\n- To use OCP CAD Viewer, start VS Code from the commandline in the Python environment you want to use or select the right Python interpreter in VS Code first. **OCP CAD Viewer depends on VS Code using the right Python interpreter** (i.e. mamba / conda / pyenv / poetry / ... environment).\n- For VSCodium, the extension is not available in the VS code market place. You need to download the the vsix file from the [release folder](https://github.com/bernhard-42/vscode-ocp-cad-viewer/releases) and install it manually.\n\n### Installation\n\n1. Open the VS Code Marketplace, and search and install _OCP CAD Viewer 2.8.9_.\n\n Afterwards the OCP viewer is available in the VS Code sidebar:\n\n \n\n2. Clicking on it shows the OCP CAD Viewer UI with the viewer manager and the library manager:\n\n \n\n You have 3 options:\n\n - Prepare _OCP CAD Viewer_ for working with [build123d](https://github.com/gumyr/build123d): Press the _Quickstart build123d_ button.\n\n This will install _OCP_, _build123d_, _ipykernel_ (_jupyter_client_), _ocp_tessellate_ and _ocp_vscode_ via `pip`\n\n \n\n - Prepare _OCP CAD Viewer_ for working with [CadQuery](https://github.com/cadquery/cadquery): Press the _Quickstart CadQuery_ button.\n\n This will install _OCP_, _CadQuery_, _ipykernel_ (_jupyter_client_), _ocp_tessellate_ and _ocp_vscode_ via `pip`\n\n \n\n - Ignore the quick starts and use the \"Library Manager\" to install the libraries via `pip` (per default, this can be changed in the VS Code settings). Install the needed library by pressing the down-arrow behind the library name (hover over the library name to see the button) in the \"Library Manager\" section of the _OCP CAD Viewer_ sidebar. For more details, see [here](./docs/install.md)\n\n Quickstart will also\n\n - (optionally) install the the [Jupyter extension for VS Code from Microsoft](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter)\n - start the OCP viewer\n - create a demo file in a temporary folder to quickly see a simple usage example\n\n\n**Notes:** \n\n- Do not use the _OCP CAD Viewer_ logo to verify your _OCP CAD Viewer_ settings! The logo overwrites all your settings in VS Code with its own settings to always look the same on each instance. Use a simple own model for checking your configuration\n\n- If you run into issues, see [Troubleshooting](#troubleshooting)\n\n## Usage\n\n### Running code using Jupyter\n\n- Start the _OCP CAD Viewer_ by pressing the box-arrow button in the \"Viewer Manager\" section of the _OCP CAD Viewer_ sidebar (hover over the `ocp_vscode` entry to see the button).\n- Import ocp_vscode and the CAD library by using the paste button being the library names in the \"Viewer Manager\" section\n- Use the usual Run menu to run the code\n\n\n\n### Debugging code with visual debugging\n\nAfter each step, the debugger checks all variables in `locals()` for being CAD objects and displays them with their variable name.\nNote:\n\n- Check that `OCP:on` is visible in the status bar\n- It also shows planes, locations and axis, so name your contexts\n- It remembers camera position and unselected variables in the tree\n- during debugging, `show` and `show_object` are disabled. They interfere with the visual debugging\n\n\n\n### Library Manager\n\nYou can also use \"Library Manager\" in the _OCP CAD Viewer_ sidebar to manage the Python libraries for _build123d_, _cadquery_, _ipython_ and _ocp_tessellate_ (Press the down-arrow when hovering over a library name to install/upgrade it)\n\n### Extra topics\n\n- [Quickstart experience on Windows](docs/quickstart.md)\n- [Use Jupyter to execute code](docs/run.md)\n- [Debug code with visual debugging](docs/debug.md)\n- [Measure mode](docs/measure.md)\n- [Object selection mode](docs/selector.md)\n- [Use the `show` command](docs/show.md)\n- [Use the `show_object` command](docs/show_object.md)\n- [Use the `push_object` and `show_objects` command](docs/push_object.md)\n- [Use the `show_all` command](docs/show_all.md)\n- [Use the `set_viewer_config` command](docs/set_viewer_config.md)\n- [Download examples for build123d or cadquery](docs/examples.md)\n- [Use the build123d snippets](docs/snippets.md)\n\n## Standalone mode\n\nStandalone mode allows to use OCP CAD Viewer without VS Code: `python -m ocp_vscode`. This will start a Flask server and the viewer can be reached under `http://127.0.0.1/viewer`. All client side feature of the VS Code variant (i.e. `show*` features) should be available (including measurement mode) except visual debugging (see above) which relies on VS Code.\n\nUse `python -m ocp_vscode --help` to understand the command line args:\n```\nUsage: python -m ocp_vscode [OPTIONS]\n\nOptions:\n --create_configfile Create the config file .ocpvscode_standalone in\n the home directory\n --host TEXT The host to start OCP CAD with\n --port INTEGER The port to start OCP CAD with\n --debug Show debugging information\n --timeit Show timing information\n --tree_width TEXT OCP CAD Viewer navigation tree width\n (default: 240)\n --no_glass Do not use glass mode with transparent\n navigation tree\n --theme TEXT Use theme 'light' or 'dark' (default:\n 'light')\n --no_tools Do not show toolbar\n --tree_width INTEGER Width of the CAD navigation tree (default:\n 240)\n --control TEXT Use control mode 'orbit'or 'trackball'\n --up TEXT Provides up direction, 'Z', 'Y' or 'L'\n (legacy) (default: Z)\n --rotate_speed INTEGER Rotation speed (default: 1)\n --zoom_speed INTEGER Zoom speed (default: 1)\n --pan_speed INTEGER Pan speed (default: 1)\n --axes Show axes\n --axes0 Show axes at the origin (0, 0, 0)\n --black_edges Show edges in black\n --grid_xy Show grid on XY plane\n --grid_yz Show grid on YZ plane\n --grid_xz Show grid on XZ plane\n --center_grid Show grid planes crossing at center of object\n or global origin(default: False)\n --collapse INTEGER leaves: collapse all leaf nodes, all:\n collapse all nodes, none: expand all nodes,\n root: expand root only (default: leaves)\n --perspective Use perspective camera\n --ticks INTEGER Default number of ticks (default: 10)\n --transparent Show objects transparent\n --default_opacity FLOAT Default opacity for transparent objects\n (default: 0.5)\n --explode Turn explode mode on\n --angular_tolerance FLOAT Angular tolerance for tessellation algorithm\n (default: 0.2)\n --deviation FLOAT Deviation of for tessellation algorithm\n (default: 0.1)\n --default_color TEXT Default shape color, CSS3 color names are\n allowed (default: #e8b024)\n --default_edgecolor TEXT Default color of the edges of shapes, CSS3\n color names are allowed (default: #707070)\n --default_thickedgecolor TEXT Default color of lines, CSS3 color names are\n allowed (default: MediumOrchid)\n --default_facecolor TEXT Default color of faces, CSS3 color names are\n allowed (default: Violet)\n --default_vertexcolor TEXT Default color of vertices, CSS3 color names\n are allowed (default: MediumOrchid)\n --ambient_intensity INTEGER Intensity of ambient light (default: 1.00)\n --direct_intensity FLOAT Intensity of direct light (default: 1.10)\n --metalness FLOAT Metalness property of material (default:\n 0.30)\n --roughness FLOAT Roughness property of material (default:\n 0.65)\n --help Show this message and exit.\n```\n\n## Standalone mode with Docker\n\nIf you are not using vscode and you prefer to keep the standalone web viewer running separated in a container,\nthen take a look at [docker-vscode-ocp-cad-viewer](https://github.com/nilcons/docker-vscode-ocp-cad-viewer).\n\n## Best practices\n\n- Use the **Jupyter extension** for a more interactive experience. This allows to have one cell (separated by `# %%`) at the beginning to import all libraries\n\n ```python\n # %%\n from build123d import *\n from ocp_vscode import *\n\n # %%\n b = Box(1,2,3)\n show(b)\n # %%\n ```\n\n and then only execute the code in the cell you are currently working on repeatedly.\n\n- The **config system** of OCP CAD Viewer\n\n There are 3 levels:\n\n - Workspace configuration (part of the VS Code settings, you can access them e.g. via the gear symbol in OCP CAD Viewer's \"Viewer Manager\" when you hover over the label \"VIEWER MANAGER\" to see the button)\n - Defaults set with the command `set_defaults` per Python file\n - Parameters in `show` or `show_object` per command\n\n `set_defaults` overrides the Workspace settings and parameters in `show` and `show_config` override the other two.\n\n Note that not all parameters are available in the global Workspace config, since they don't make sense globally (e.g. `helper_scale` which depends on the size of the boundary box of the currently shown object)\n\n A common setup would be\n\n ```python\n # %%\n from build123d import *\n import cadquery as cq\n\n from ocp_vscode import *\n set_port(3939)\n\n set_defaults(reset_camera=False, helper_scale=5)\n\n # %%\n ...\n ```\n\n Explanation\n\n - The first block imports build123d and CadQuery (omit what you are not interested in).\n - The second block imports all commands for OCP CAD Viewer. `set_port` is only needed when you have more than one viewer open and can be omitted for the first viewer)\n - The third block as an example sets helper_scale and reset_camera as defaults. Then every show_object or show command will respect it as the default\n\n- Debugging build123d with `show_all` and the **visual debugger**\n\n - If you name your contexts (including `Location` contexts), the visual debugger will show the CAD objects assigned to the context.\n\n - Use `show_all` to show all cad objects in the current scope (`locals()`) of the Python interpreter (btw. the visual debugger uses `show_all` at each step)\n\n ```python\n # %%\n from build123d import *\n set_defaults(helper_scale=1, transparent=True)\n\n with BuildPart() as bp:\n with PolarLocations(3,8) as locs:\n Box(1,1,1)\n\n show_all()\n # %%\n ```\n\n \n\n- **Keep camera orientation** of an object with `reset_camera`\n\n Sometimes it is helpful to keep the orientation of an object across code changes. This is what `reset_camera` does:\n\n - `reset_camera=Camera.Center` will keep position and rotation, but ignore panning. This means the new object will be repositioned to the center (most robust approach)\n - `reset_camera=Camera.KEEP` will keep position, rotation and panning. However, panning can be problematic. When the next object to be shown is much larger or smaller and the object before was panned, it can happen that nothing is visible (the new object at the pan location is outside of the viewer frustum). OCP CAD Viewer checks whether the bounding box of an object is 2x smaller or larger than the one of the last shown object. If so, it falls back to `Camera.CENTER`. A notification is written to the OCP CAD Viewer output panel.\n - `reset_camera=Camera.RESET` will ensure that position, rotation and panning will be reset to the initial default\n\n## Development\n\nTesting:\n\nNative tessellator can be set via `NATIVE_TESSELLATOR=1` and Python tessellator via `NATIVE_TESSELLATOR=0`.\n\nWhen `OCP_VSCODE_PYTEST=1` is set, `show` will not send the tessellated results to the viewer, but return it to the caller for inspection.\n\nA full test cycle consist of:\n\n```bash\nNATIVE_TESSELLATOR=0 OCP_VSCODE_PYTEST=1 pytest -v -s pytests/\nNATIVE_TESSELLATOR=1 OCP_VSCODE_PYTEST=1 pytest -v -s pytests/\n```\n\n## Troubleshooting\n\n- **Generic (\"it doesn't work\")**\n\n 1) Confirm that VS Code extension and ocp_vscode have the same version. This can be seen in the OCP CAD Viewer UI. Or alternatively in the Output panel of VS Code:\n\n ```text\n 2025-07-06 14:51:33.418 [info ] extension.check_upgrade: ocp_vscode library version 2.8.6 matches extension version 2.8.6\n ```\n\n 2) Test whether the standalone viewer works, see [Standalone mode](#standalone-mode) (to eliminate VS Code issues)\n 3) Open a work folder and not a Python file (to ensure we do not get in Python path problems)\n 4) Check the Output panel. Search for:\n - `PythonPath: 'aaa/bbb/python'` **=> right Python environment?**\n - `Server started on port xxxx` (or so) **=> right port? default is 3939**\n - `Starting Websocket server` **=> should not be followed by an error**\n - `OCP Cad Viewer port: xxxx, folder: yyyy zzzz` **=> yyyy should be the right working folder?**\n 5) If all looks fine until now, then toggle Developer tools in VS Code and check browser console. Often we see a WebGL error for the browser of VS Code used for the viewer.\n\n\n- **CAD Models almost always are invisible in the OCP viewer window**\n\n ```bash\n three-cad-viewer.esm.js:20276 THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false\n\n Material Name:\n Material Type: LineBasicMaterial\n\n Program Info Log: Program binary could not be loaded. Binary is not compatible with current driver/hardware combination. Driver build date Mar 19 2024. Please check build information of source that generated the binary.\n Location of variable pc_fragColor conflicts with another variable.\n ```\n\n VS Code internal browser that renders the viewer component uses a cache for code and other artifacts. This includes WebGL artifacts like compiled shaders. It can happen that e.g. due to a graphic driver update the compiled version in the cache does not fit to the new driver. Then this error message appears.\n\n **Solution:** [Delete the VS Code browser cache on Linux](https://bobbyhadz.com/blog/vscode-clear-cache) (go to the section for your operating system)\n\n## Changes\n\n### v2.8.9\n\n**Fixes**\n\n- Add a robuts port in use detection to Windows\n\n### v2.8.8\n\n**Fixes**\n\n- Fix regression of wrong level for continue statement leading to show_all crashing\n\n### v2.8.7\n\n**Fixes**\n\n- Startup now checks all visible python files for trigger statements. If any has, autostart kicks in.\n- More than two Viewer columns are supported\n- Fixed a bug where an empty `~/.ocpvscode` file crashed `show` [#183](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/183)\n- Fixed calling jupyter console \n- Moved all `show_all` warnings behind `debug=True` parameter\n\n### v2.8.6\n\n**Features**\n\n- Fixed blank viewer issue by resolving a race condition properly ([#171](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/171))\n- Made statements that trigger OCP CAD Viewer to start editable in settings (`Ocp Cad Viewer > Advanced : Autostart Triggers`). They now default to `import ocp_vscode` and `from ocp_vscode import` and don't include \"build123d\" and \"cadquery\" any more\n- Set backend precision to 3 ([#179](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/179))\n- Clicking on a tree label with shift+meta hides all others without change of location ([#178](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/178))\n- Hid the `show_all` warnings about non viewable types. Can still be seen with the `debug` parameter\n- Added a button to the quickstart welcome screen to change the environment\n\n**Fixes**\n\n- Fix broken check for ocp_vscode when it is installed in user site-packages ([#181](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/181))\n- Ensured to refresh library and viewer manager at VS Code start, even when build123d is not imported ([#177](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/177))\n- Fix broken helix discretizing ([#176](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/176))\n- Ensure that lines and arrows for measurements are initialized once only to remove memory leaks ([#29](https://github.com/bernhard-42/three-cad-viewer/issues/29)) \n- Disable text selection of UI elements except info box\n- Fix isolate mode when there are only 1-dim objects in the viewer ([#178](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/178))\n- Keep camera position when \"Isolate element\" action is taken ([#174](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/174))\n\n### v2.8.5\n\n**Fixes**\n\n- Clean up viewerStarting flag in error case\n- Fix broken handling of mirrored curve in ocp-tessellate ([#170](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/170))\n- Remove deviding line deflection by 100 ([#172](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/172))\n\n### v2.8.4\n\n**Fixes**\n\n- Add handling of view log mesage forwarding to standalone mode\n\n### v2.8.3\n\n**Fixes**\n\n- Fix dual stack port detection on Linux ([#171](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/171))\n- Close old viewer window if exists on viewer start\n\n### v2.8.2\n\n**Features**\n\n- Add clear and update params to push_object\n- Add removal and update of an individual part in show_object\n- Introduce shortcuts select_face, select_edge, select_vertex for the selection mode\n\n**Fixes**\n\n- Rewrite port check and add more debug info\n- Ensure to wait for all async functions at startup\n- Fix grid_xz / grid_yz mix-up in standalone mode\n- Improve logging during viewer start\n\n### v2.8.1\n\n***Fixes**\n\n- Fixed typos in doc strings and everywhere else\n- Fixed a f-string issue with broken quotes\n- Enhanced port running check to tcp4 and tcp6\n- Documented visual debugging with pdb ([#164](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/164))\n\n### v2.8.0\n\n**Features**\n\n- Add a color marker behind the node name of the navigation tree showing the object color\n- New \"select objects\" mode that allows to retrieve stable object indices that can be used in python code to select objects\n- Removed the need of an open workspace. If the extension cannot identify a Python environment with ocp_vscode, it asks for it. ([#160](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/160), [#163](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/163))\n- Simplified port detection. Every viewer stores its port into `~/.ocpvscode`. If mode than one active port is detected, show let's you select the right one ([#163](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/163))\n- Improve startup reliability and performance\n- Allow setting port in launch.json\n- Add `include` argument to `show_all`\n- Add `push_object` and `show_objects` to control showing objects in a lazy manner\n- Bump to three-cad-viewer 3.4.0\n\n\n**Fixes**\n- Clean up startup sequence and fix start issues with Jupyter interactive window\n- Fix disposing all viewer objects on closing the viewer\n- Ensure revive of viewer is not used in autostart mode\n- Improve pip list parsing\n- Start backend with a temp folder instead of work directory\n- Fix naming `vertex0` to `vertex_0` (and so on) in exploded mode (three-cad-viewer)\n- Fix clear and dispose behavior (three-cad-viewer [#27](https://github.com/bernhard-42/three-cad-viewer/issues/27))\n- Fix `save_screenshot` throwing an error ([#162](https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues/162))\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "OCP CAD Viewer for VSCode",
"version": "2.8.9",
"project_urls": {
"Bug Tracker": "https://github.com/bernhard-42/vscode-ocp-cad-viewer/issues",
"Homepage": "https://github.com/bernhard-42/vscode-ocp-cad-viewer"
},
"split_keywords": [
"3d models",
" 3d printing",
" 3d viewing",
" 3d",
" brep",
" cad",
" cadquery",
" opencscade",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2e43143fca1f618d29903a13bb0e29be7490dc047ea62c1704aa1ce15ac6fb4b",
"md5": "d80a4e0b4790b54a0a6233275359fed3",
"sha256": "850220ee0feb11895fc4d5d6685ebe043ca08ad5931ae67a4bdcce10a786ea7a"
},
"downloads": -1,
"filename": "ocp_vscode-2.8.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d80a4e0b4790b54a0a6233275359fed3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 488627,
"upload_time": "2025-07-19T15:22:02",
"upload_time_iso_8601": "2025-07-19T15:22:02.241291Z",
"url": "https://files.pythonhosted.org/packages/2e/43/143fca1f618d29903a13bb0e29be7490dc047ea62c1704aa1ce15ac6fb4b/ocp_vscode-2.8.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3a852cb9b654b6e469cd6e7a642d2a5273ce1da3d3a109a1d41e8ed28bb49cf3",
"md5": "dd3643973bda13ddef4f2627f3bae61e",
"sha256": "daf5ae9953b6276462dba1de307607886a17b14243c3bbba5e37a59dfbb9aacc"
},
"downloads": -1,
"filename": "ocp_vscode-2.8.9.tar.gz",
"has_sig": false,
"md5_digest": "dd3643973bda13ddef4f2627f3bae61e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 486059,
"upload_time": "2025-07-19T15:22:03",
"upload_time_iso_8601": "2025-07-19T15:22:03.874162Z",
"url": "https://files.pythonhosted.org/packages/3a/85/2cb9b654b6e469cd6e7a642d2a5273ce1da3d3a109a1d41e8ed28bb49cf3/ocp_vscode-2.8.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-19 15:22:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bernhard-42",
"github_project": "vscode-ocp-cad-viewer",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ocp-vscode"
}