ParaView/Python/Animation

From KitwarePublic
< ParaView
Revision as of 20:53, 22 May 2009 by Berk (talk | contribs)
Jump to navigationJump to search

Animating time series

Server Manager has a complicated animation engine based on keyframes and scenes. This section will introduce a few simple ways of animating your visualization. If you have a time-aware reader, you can animate it with AnimateReader().

<source lang="python"> reader = ExodusIIReader(“.../can.ex2”) Show(reader) Render() c = GetActiveCamera() c.Elevation(95)

  1. Animate over all time steps. Note that we are not passing the optional
  2. 3rd argument here. If you pass a filename as the 3rd argument,
  3. AnimateReader will create a movie.

AnimateReader(reader)

  1. Save the animation to an avi file

AnimateReader(reader, filename=".../movie.avi") </source>

Animating properties

To animate properties other than time, you can use regular keyframes.

<source lang="python"> Sphere() Show() Render()

  1. Create an animation scene

scene = servermanager.animation.AnimationScene()

  1. Add one view

scene.ViewModules = [GetActiveView()]

  1. Create a cue to animate the StartTheta property

cue = servermanager.animation.KeyFrameAnimationCue() cue.AnimatedProxy = GetActiveSource() cue.AnimatedPropertyName = "StartTheta"

  1. Add it to the scene's cues

scene.Cues = [cue]

  1. Create 2 keyframes for the StartTheta track

keyf0 = servermanager.animation.CompositeKeyFrame() keyf0.Interpolation = 'Ramp'

  1. At time = 0, value = 0

keyf0.KeyTime = 0 keyf0.KeyValues= [0]

keyf1 = servermanager.animation.CompositeKeyFrame()

  1. At time = 1.0, value = 200

keyf1.KeyTime = 1.0 keyf1.KeyValues= [200]

  1. Add keyframes.

cue.KeyFrames = [keyf0, keyf1]

scene.Play()

  1. Some properties you can change
  2. Number of frames used in Sequence mode
  3. scene.NumberOfFrames = 100
  4. Or you can use real time mode
  5. scene.PlayMode = 'Real Time'
  6. scene.Duration = 20

</source>