Python script overlay

This type of viewport overlay allows you to write a custom Python script function to paint arbitrary text and graphics on top of images rendered by OVITO. This makes it possible to enrich a figure or a movie with additional information (e.g. a scale bar or data plots, see the examples below).

The Edit script button opens the code editor where you enter the code for the custom render() function. This function is invoked by OVITO each time the viewport needs to be repainted or when an image or movie frame is being rendered. The function's first parameter is a QPainter object, which allows to issue arbitrary drawing command and paint over the picture of the three-dimensional scene rendered by OVITO. The second parameter, args, is a dictionary containing additional information such as the viewport being rendered, the general render settings, and the viewport's projection parameters.

Any errors that occur during script execution are displayed in the output area below. It also shows any output generated by 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 results. For more information on OVITO's Python interface and the object model, see the Scripting Reference.