Code examples
This page presents complete example scripts and extensions, which you can use as starting points for your own work. The OVITO Extensions Directory contains many more Python extensions shared by other users.
Python scripts
Python scripts
Python scripts that use OVITO as a library to perform analysis or visualization tasks non-interactively (see Two ways of using OVITO’s Python API). You run them with a Python interpreter or ovitos.
User-defined modifiers
OVITO Pro Python scripts
User-defined modifiers written in Python, which you can use in OVITO Pro or insert into a pipeline in a Python script.
- 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
- Example M7: Displacement vectors with reference configuration
- Example M8: Compute trajectory average of a global attribute
User-defined viewport layers
OVITO Pro Python scripts
User-defined viewport layers, which enrich rendered images and movies with text or graphics, e.g. data plots computed from the simulation data. In OVITO Pro, they also appear in the interactive viewports.
User-defined file readers
OVITO Pro Python scripts
User-defined file readers for importing data from new file formats. Once installed, they take part in the
automatic format detection of OVITO Pro’s file import function and of the import_file() function.