This module defines the
Scene class, which serves as a “universe” or context for all actions
performed by a script. The global scene object is accessible as module-level variable
The scene manages a list of
Pipeline objects, which will be visible in images and videos
when rendering the scene through a
Viewport. Furthermore, you can save the entire
scene definition including all pipelines to a
.ovito session state file, which can be opened in the graphical OVITO application.
This module-level variable points to the global
Sceneobject, which serves as context for all operations performed by the script. The
Sceneobject represents the program state and provides access to the contents of the visualization scene:
import ovito # Retrieve the output data of the pipeline that is currently selected in OVITO: data = ovito.scene.selected_pipeline.compute()
A module-level attribute reporting the OVITO program version number (as a tuple of three
Module-level attribute reporting the OVITO program version (as a string).
- class ovito.Scene
This class encompasses all data of an OVITO program session (basically everything that gets saved in a
.ovitostate file). It manages the list of objects (i.e.
Pipelineinstances) that are part of the three-dimensional scene and which will show up in rendered images.
From a script’s point of view, there exists exactly one universal instance of this class at any time, which is accessible through the
ovito.scenemodule-level variable. A script cannot create another
Sceneinstance by itself.
Loads the pipeline(s) stored in a .ovito session state file. This function works like the Load Session State function of the graphical OVITO application. It can load session state files that were produced with the interactive OVITO application or which have been written by the
filename (str) – File path of the .ovito session file to load
After the state file has been loaded, the
pipelineslist will be populated with exact copies of the data pipelines that were part of the scene when it was saved. See also this section for more information.
- property pipelines
The list of
Pipelineobjects that are currently part of the three-dimensional scene. Only pipelines in this list will display their output data in the viewports and in rendered images. You can add or remove a pipeline either by calling its
remove_from_scene()methods or by directly manipulating this list using the standard Python
from ovito import scene from ovito.io import import_file pipeline = import_file('input/simulation.dump') # Insert the pipeline into the visualization scene. pipeline.add_to_scene() # It's now part of the 'scene.pipelines' list. assert(pipeline in scene.pipelines) # If needed, we can take it out again. pipeline.remove_from_scene()
Saves the scene to a
.ovitosession state file. The scene comprises the definition of all pipelines currently in the
Scene.pipelineslist as well as the modifiers and visual elements that are part of these pipelines. This function works like the Save Session State As function of the OVITO desktop application.
filename (str) – Output file path
The saved session state may be restored again from disk by
After the state file has been loaded back from disk, the global
Scene.pipelineslist will contain again all pipeline objects that were part of the scene at the time it was saved. See also the section Saving and loading pipelines.
- property selected_pipeline
This field can be useful for macro scripts running in the context of an interactive OVITO session, which perform some action on the currently selected pipeline such as inserting a modifier.
Call this function at the beginning of your Python script to activate logging of otherwise unnoticeable operations performed by OVITO. Subsequently, when it performs long-running work or computations, OVITO will print messages to
stderrindicating the current activity, e.g. file I/O, modifier execution, and image rendering.