Table of Contents | Python script viewport layer pro | Up
Prev | Viewport layers | Next

#### Python script viewport layer pro

This type of viewport layer lets you write your own Python script function to paint arbitrary text and graphics on top of images rendered in OVITO. This makes it possible to enrich figures or movies with additional information (e.g. a scale bar or a data plot).

The Edit script button opens a code editor, where you enter the code for the user-defined `render()` function. This function will be invoked by OVITO each time the viewport is repainted or whenever an image or movie frame is being rendered. The function parameter `args` gives access to a `QPainter` object, which allows issueing arbitrary drawing commands to paint over the three-dimensional objects rendered by OVITO.

Any Python exceptions that raised during script execution are displayed in the output area below. It also shows any output from calls to the `print()` Python function.

The user-defined script has full access to OVITO's data model and can access viewport properties, camera and animation settings, modifiers, and data pipeline outputs. For more information on OVITO's Python interface and the object model, see the scripting reference.

##### Examples

This page provides several code examples demonstrating how to write a `render()` function for a Python viewport layer:

- Scale bar
- Including data plots in rendered images
- Highlight a particle

##### See also

`PythonViewportOverlay` (Python API) pro

Prev | Up | Next
Coordinate tripod viewport layer | Table of Contents | Text label viewport layer