[Paraview] Scripting the animation of a slice
Utkarsh Ayachit
utkarsh.ayachit at kitware.com
Tue May 26 09:12:40 EDT 2009
The plane use for slicing is an another proxy accessible as:
cut.CutFunction[0]
cut.CutFunction[0].ListProperties() should show you the available properties
(one of them is the Origin).
Likewise, opacity if a property on the representation for the source in the
view. The following code will help you locate the representation for the
slice filter.
view = servermanager.GetRenderView()
cut_repr = None
for rep in view.Representations:
if rep.Input[0].Proxy == cut:
cut_repr = rep
break
cut_repr.ListProperties() will show the properties available, one of them
will be Opacity.
Utkarsh
p.s. this is for 3.4. In 3.6 onwards there are easier ways of accessing the
representation.
On Tue, May 26, 2009 at 4:28 AM, Wim van der Meer
<wpjvandermeer at gmail.com>wrote:
> 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()
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090526/f31662a2/attachment.htm>
More information about the ParaView
mailing list