[Paraview] Animation with pvbatch

Mathias Winkel win_wa at gmx.net
Tue Jul 16 16:28:59 EDT 2013


Dear all,

Finally, I found a solution for my problem. A working example script is 
given below: I am now reading the TimestepValues from my data source and 
setting ANI.AnimationTime and (!) VIEW.ViewTime appropriately.
Still I do not know why GoToNext() etc. do not work from pvbatch. - Are 
they only applicable for the ParaView GUI?

Best Regards,

Mathias

8<---------------------------------------
directory='./'
filenamein='paraview_juvis_NEU.pvsm'
filenamedata='particles.timeseries.pvd'
filenameout='animation.%6.6d.png'

from paraview.simple import *

#servermanager.Connect()
servermanager.LoadState("%s%s" % (directory, filenamein) )
SRC=FindSource(filenamedata)
VIEW=GetRenderView()

BAR=CreateScalarBar(LookupTable=GetLookupTableForArray( "p_y (el)", 1 ), 
Title="p_y (el)")
BAR.Position=[0.8, 0.55]
BAR.Position2=[0.1, 0.35]
BAR.LabelFontSize=10
BAR.TitleFontSize=10
VIEW.Representations.append(BAR)

BAR=CreateScalarBar(LookupTable=GetLookupTableForArray( "p_y (ion)", 1 
), Title="p_y (ion)")
BAR.Position=[0.8, 0.05]
BAR.Position2=[0.1, 0.35]
BAR.LabelFontSize=10
BAR.TitleFontSize=10
VIEW.Representations.append(BAR)

SetActiveView(VIEW)

ANI=GetAnimationScene()
ANI.Caching=False

for idx in range(3):#len(SRC.TimestepValues)):
   print idx, SRC.TimestepValues[idx]
   ANI.AnimationTime = SRC.TimestepValues[idx]
   VIEW.ViewTime = ANI.AnimationTime
   VIEW.StillRender()
   WriteImage("%s%s" % (directory, filenameout % idx))

Am 7/16/2013 9:45 PM, schrieb Mathias Winkel:
> Hello,
>
> I am trying to produce an animated series of images with pvbatch and the
> scriptbelow. The pvsm fileloads a pvd file with a time series and
> applies a number of filters.
> When executed in the Paraview GUI (version 4.0.1) via Tools->Python
> Shell->Run Script, it successfully steps through the animation.
>
> Whenrun with pvbatch, I see the correct output of "print AN.EndTime"
> (2999- the same number as when run in the GUI), but AN.GoToNext()
> apparently does nothing and the loop immediately terminates after one
> step with newtime==oldtime==0.0. What am I doing wrong?
> I browsed through numerous examples for animation with pvbatch but none
> of them did really fit (most of them are rather old or use
> AnimateReader() which does not seem to be appropriate here).
> Do you have a suggestions?
>
> Thanks in advance,
>
> Mathias
>
>
>
>
>
> 8<-----------------------------------------
>
> from paraview.simple import *
>
> servermanager.LoadState("paraview.pvsm")
>
> V=GetRenderView()
> SetActiveView(V)
>
> AN=GetAnimationScene()
> AN.Caching=False
> AN.GoToFirst()
>
> oldtime = -1
> newtime = AN.AnimationTime
>
> print AN.EndTime
>
> while newtime>oldtime:
>    print newtime
>    V.StillRender()
>    #WriteImage("animation_%6.6d.png" % int(newtime))
>    AN.GoToNext()
>    oldtime = newtime
>    newtime = AN.AnimationTime
>    print oldtime, newtime
> _______________________________________________
> 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



More information about the ParaView mailing list