[Paraview] Scripting the animation of a slice

Wim van der Meer wpjvandermeer at gmail.com
Tue May 26 04:28:47 EDT 2009


Hi,

I am a new ParaView user, and although there are some quirks, I like it so far.

I am now writing a script to write out an animation. One part of the
animation involves animating a slice filter moving in the z-direction.
When I create the animation using the GUI, in the "Animation View"
window I add a track for "Slice1" and select the "Slice Type - Origin
(2)" property. This works fine. I am unable to find out, however, what
the property name is for the slice object when creating the animation
in Python.

Another property I would like to animate is opacity of the data.
Again, using the GUI this works fine, but I can't figure out how to do
this in a script.

Neither calling ListProperties() on the object or dir() gets me any
further. Any help would be greatly appreciated.

I run my script from the ParaView 3.4.0 built-in Python shell. The
data is in Legacy VTK format. This is the script I have so far:

#!/usr/bin/python
# -*- coding: utf-8 -*-

#################################################
# parameters
filename = "test.avi"
fps = 12.0 # frames/seconds

#################################################
# preparation
view = servermanager.GetRenderView()
camera = view.GetActiveCamera()

movie = servermanager.animation.AnimationScene()
movie.ViewModules = [view]
movie.NumberOfFrames = fps * totaltime

pm = servermanager.ProxyManager()

#################################################
# cue 1: animating horizontal slices
data = pm.GetProxy("sources", "data.vtk")
bounds = data.GetDataInformation().DataInformation.GetBounds()
startZ = bounds[5]
endZ = bounds[4]

cut = pm.GetProxy("sources", "Slice1")

cue1 = servermanager.animation.KeyFrameAnimationCue()
cue1.AnimatedProxy = cut

# What is the name of the property to change the z- position of the slice?
cue1.AnimatedPropertyName = "InputBounds" # <---------This does not work!!!

# two key frames with ramp interpolation
keyf0 = servermanager.animation.CompositeKeyFrame()
keyf0.Type = 2 # Set keyframe interpolation type to Ramp.
keyf0.KeyTime = 0
keyf0.KeyValues= [startZ]

keyf1 = servermanager.animation.CompositeKeyFrame()
keyf1.KeyTime = 1.0
keyf1.KeyValues= [endZ]

cue1.KeyFrames = [keyf0, keyf1]

movie.AddCueProxy(cue1)

#################################################
# Play the animation
#movie.Play()

#################################################
# Save the animation as an AVI movie
movieWriter = servermanager.vtkSMAnimationSceneImageWriter()
movieWriter.SetFrameRate(fps)
movieWriter.SetFileName(filename)
movieWriter.SetAnimationScene(movie.SMProxy)
movieWriter.Save()


More information about the ParaView mailing list