Animation#

class ansys.tools.visualization_interface.backends.pyvista.animation.Animation(plotter: pyvista.Plotter, frames: FrameSequence | List[Any], fps: int = 30, loop: bool = False, scalar_bar_args: dict | None = None, **plot_kwargs)#

Animation controller for PyVista visualizations.

This class manages animation playback, providing play/pause/stop controls, frame stepping, timeline scrubbing, and export capabilities.

Parameters:
plotterpv.Plotter

PyVista plotter instance to animate.

framesFrameSequence or List[Any]

Frame sequence or list of frame objects to animate.

fpsint, optional

Frames per second for playback (default: 30).

loopbool, optional

Whether to loop animation continuously (default: False).

scalar_bar_argsdict, optional

Scalar bar and rendering arguments to apply. Supports: - clim : tuple - Fixed color scale (min, max) for all frames - title : str - Scalar bar title - color : str - Scalar bar text color - Other parameters accepted by PyVista’s add_mesh method

Examples

Create and play a simple animation:

>>> from ansys.tools.visualization_interface import Plotter
>>> plotter = Plotter(backend='pyvista')
>>> frames = [mesh1, mesh2, mesh3]
>>> animation = plotter.animate(frames, fps=30, loop=True)
>>> animation.play()

Overview#

play

Start or resume animation playback.

pause

Pause animation playback.

stop

Stop animation and reset to first frame.

step_forward

Advance one frame forward.

step_backward

Rewind one frame backward.

seek

Jump to specific frame.

save

Export animation to video file.

show

Display animation with the plotter.

state

Current animation state.

current_frame

Current frame index.

total_frames

Total number of frames.

fps

Frames per second.

Import detail#

from ansys.tools.visualization_interface.backends.pyvista.animation import Animation

Property detail#

property Animation.state: AnimationState#

Current animation state.

property Animation.current_frame: int#

Current frame index.

property Animation.total_frames: int#

Total number of frames.

property Animation.fps: int#

Frames per second.

Method detail#

Animation.play()#

Start or resume animation playback.

Animation.pause()#

Pause animation playback.

Animation.stop()#

Stop animation and reset to first frame.

Animation.step_forward()#

Advance one frame forward.

Animation.step_backward()#

Rewind one frame backward.

Animation.seek(frame_index: int)#

Jump to specific frame.

Parameters:
frame_indexint

Target frame index.

Animation.save(filename: str | pathlib.Path, quality: int = 5, framerate: int | None = None, close_plotter: bool = False)#

Export animation to video file.

Parameters:
filenamestr or Path

Output filename (.mp4, .gif, .avi).

qualityint, optional

Video quality (1-10, higher is better). Default is 5.

framerateint, optional

Output framerate. If None, uses animation fps.

close_plotterbool, optional

If True, closes plotter after saving. Default is False.

Animation.show(show_controls: bool = True, **kwargs)#

Display animation with the plotter.

Parameters:
show_controlsbool, optional

If True, shows interactive controls. Default is True.

**kwargs

Additional arguments passed to plotter.show().