# Code examples

This page presents various example scripts grouped into the following categories.

## Batch scripts

As described in Introduction, batch scripts perform program actions in a non-interactive manner and are typically executed from the system terminal via the ovitos script interpreter. The following examples demonstrate how to automate tasks and accomplish new things that cannot even be done with the graphical program version.

- Example B1: Computing Voronoi indices
- Example B2: Computing CNA bond indices
- Example B3: Creating particles and bonds programmatically

## Python modifier functions

OVITO allows you to implement your own type of analysis modifier by writing a Python function that gets called every time the data pipeline is evaluated. This user-defined function has access to the positions and other properties of particles and can output information and results as new properties or global attributes.

- Example M1: Calculating mean square displacement
- Example M2: Custom order parameter calculation
- Example M3: Color mapping to visualize local lattice orientation
- Example M4: Finding overlapping particles
- Example M5: Shrink-wrap simulation box
- Example M6: Calculate local entropy

## Python viewport layer functions

OVITO allows you to implement your type of viewport layer by writing a Python function that gets called every time a viewport image is being rendered.

- Example O1: Scale bar
- Example O2: Including data plots in rendered images
- Example O3: Highlight a particle