ovito

ovito.dataset

This module-level attribute holds the current DataSet, a global object representing the state of the program. It provides access to OVITO’s viewports, the objects in the scene, and the current animation and render settings.

ovito.version

This module-level attribute contains the OVITO program version (encoded as a 3-tuple).

class ovito.DataSet

A container object holding all data associated with an OVITO program session. It provides access to the scene data, the viewports, the current selection, and the animation settings. Basically everything that would get saved in an OVITO file.

There exists only one global instance of this class, which can be accessed via the ovito.dataset module-level attribute.

anim

An AnimationSettings object, which manages various animation-related settings in OVITO such as the number of frames, the current frame, playback speed etc.

render_settings

The global RenderSettings object, which stores the current settings for rendering pictures and movies. These are the settings the user can edit in the graphical version of OVITO.

save(filename)

Saves the dataset, including the viewports, all objects that are part of the scene, modification pipelines, and other settings, to an OVITO file. This function works like the Save State As function in OVITO’s file menu.

scene_nodes

A list-like object containing the ObjectNode instances that are part of the three-dimensional scene. Only nodes in this list are visible in the viewports. You can add or remove nodes from this list.

selected_node

The ObjectNode that is currently selected in OVITO’s graphical user interface, or None if no node is selected.

viewports

A ViewportConfiguration object managing the viewports in OVITO’s main window.

class ovito.ObjectNode

Manages a data source, a modification pipeline, and the output of the pipeline.

An ObjectNode is created when a new object is inserted into the scene, for example, as a result of calling py:func:~ovito.io.import_file.The node maintains a modification pipeline, which allows applying modifiers to the input data. The output of the modification pipeline is displayed by the ObjectNode in the three-dimensional scene shown by the viewport.

The data entering the modification pipeline is provided by the node’s ObjectNode.source object,which can be a FileSource or a DataCollection, for example. The node’s modification pipeline can be accessed through the ObjectNode.modifiers attribute. An evaluation of the modification pipeline can be requested by calling the ObjectNode.compute() method. Finally, the cached output of the pipeline can be accessed through the the node’s ObjectNode.output attribute.

compute()

Computes and returns the results of the node’s modification pipeline.

This method requests an update of the node’s modification pipeline and waits until the effect of all modifiers in the node’s modification pipeline has been computed. If the modification pipeline is already up to date, i.e., results are already available in the node’s pipeline cache, the method returns immediately.

Even if you are not interested in the final data that leaves the modification pipeline, you should call this method in case you are going to directly access information provided by individual modifiers in the pipeline. This method will ensure that all modifiers have been computed and their output fields are up to date.

This function raises a RuntimeError when the modification pipeline could not be successfully evaluated for some reason. This may happen due to invalid modifier parameters for example.

Returns:A reference to the node’s internal DataCollection containing the output of the modification pipeline. It is also accessible via the output attribute after calling compute().
modifiers

The node’s modification pipeline.

This list contains the modifiers that are applied to the input data provided by the node’s source object. You can add and remove modifiers from this list as needed. The first modifier in the list is always evaluated first, and its output is passed on to the second modifier and so on. The results of the last modifier are displayed in the viewports and can be access through the output field.

Example:

node.modifiers.append(WrapPeriodicImagesModifier())
output

Provides access to the last results computed by the node’s data modification pipeline.

After calling the compute() method, this attribute holds a DataCollection with the output of the node’s modification pipeline.

remove_from_scene()

Removes the node from the scene by deleting it from the ovito.DataSet.scene_nodes list. The visual representation of the node will disappear from the viewports after calling this method.

source

The object that provides or generates the data that enters the node’s modification pipeline. This typically is a FileSource instance if the node was created by a call to import_file().