ParaView/Python/Animation: Difference between revisions
Daviddoria (talk | contribs) m (moved Animation to ParaView/Python/Animation) |
JPouderoux (talk | contribs) mNo edit summary |
||
Line 63: | Line 63: | ||
# scene.Duration = 20 | # scene.Duration = 20 | ||
</source> | </source> | ||
Back to [[ParaView/PythonRecipes]]. | |||
{{ParaView/Template/Footer}} |
Revision as of 18:38, 16 October 2018
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)
- Animate over all time steps. Note that we are not passing the optional
- 3rd argument here. If you pass a filename as the 3rd argument,
- AnimateReader will create a movie.
AnimateReader(reader)
- 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()
- Create an animation scene
scene = servermanager.animation.AnimationScene()
- Add one view
scene.ViewModules = [GetActiveView()]
- Create a cue to animate the StartTheta property
cue = servermanager.animation.KeyFrameAnimationCue() cue.AnimatedProxy = GetActiveSource() cue.AnimatedPropertyName = "StartTheta"
- Add it to the scene's cues
scene.Cues = [cue]
- Create 2 keyframes for the StartTheta track
keyf0 = servermanager.animation.CompositeKeyFrame() keyf0.Interpolation = 'Ramp'
- At time = 0, value = 0
keyf0.KeyTime = 0 keyf0.KeyValues= [0]
keyf1 = servermanager.animation.CompositeKeyFrame()
- At time = 1.0, value = 200
keyf1.KeyTime = 1.0 keyf1.KeyValues= [200]
- Add keyframes.
cue.KeyFrames = [keyf0, keyf1]
scene.Play()
- Some properties you can change
- Number of frames used in Sequence mode
- scene.NumberOfFrames = 100
- Or you can use real time mode
- scene.PlayMode = 'Real Time'
- scene.Duration = 20
</source>
Back to ParaView/PythonRecipes.