Table of Contents | Python code generator pro | Up
Prev | Data pipelines | Next

### Python code generator pro

OVITO Pro includes a Python code generation function, which can turn any data pipeline created with the graphical user interface into a corresponding sequence of Python script statements, which may subsequently be executed outside of OVITO to automate data post-processing or visualization workflows. While you interactively adjust the parameters of modifiers, the code generation function produces corresponding script statements for OVITO's Python programming interface. The generated source code may be saved to disk, further customized if desired, and then run using the embedded ovitos script interpreter or any regular Python interpreter after installing the `ovito` Python module.

The Python code generator is invoked by selecting File → Generate Python script from the menu. The code generator window displays the dynamically generated source code, which gets updated in realtime while you make changes to the data pipeline or a modifier's settings.

You can activate the Visualization code option to let OVITO additionally generate code statements that set up the virtual camera, render settings, and the visual appearance of the dataset exactly as you prescribed it in the graphical user interface. This option is useful if you are going to use the generated Python script for automating image and animation rendering tasks.

#### Supported features

The code generator can generate Python staments for the following aspects of the visualization scene:

- Data file import (all arguments of the `import_file()` function)
- Visual elements
- Modifiers
- Viewport layers
- Viewport camera setup
- Rendering engine configuration
- Image/animation render settings

The following aspects are not covered by the code generator yet:

- Direct modifications you make to imported data objects, e.g. particle type colors and radii
- Data file export
- Key-frame based parameter and object animations

Thus, you have may have to amend the generated script with corresponding code statatements yourself to take care of these things. See the sections Data export and Setting the particle type radius in the OVITO Python API documentation on how to do that.

Prev | Up | Next
Pipeline cloning | Table of Contents | Data object types