[Paraview] Animation script from files

Kent Eschenberg eschenbe at psc.edu
Wed Jun 25 11:50:00 EDT 2008


Here is a "pseudo Python" script to do that. Sorry I don't have time to cleanup and post my batch script. In this I am assuming that the reader cannot properly switch from one file to another correctly so a new instance of the reader is created for each file.

=======
initialize PV in Python
   I'll call the instance of RenderView "view"
create entire pipeline except for the reader
   this is something like filter1->filter2->filter3
   create a representation of the final filter
   don't forget to set the camera
for N input files
   set the strings "infile" and "outfile"
   create reader and set "infile"
   connect the reader to filter1
   view.StillRender() (may not be needed but seems to help)
   view.WriteImage( outfile, "vtkPNGWriter" )
      this updates the pipeline which reads the input
   delete the reader
======

The values for the "infile" string could be anything. You could even have your Python script to read them from a file.

In the loop pick strings for "outfile" like "frame0000.png", "frame0001.png", etc. When done use a good movie encoder to convert the frames to a movie file.

pvbatch will probably display each frame. On the command line it will accept the option "--use-offscreen-rendering" but I'm not sure if that will eliminate the display (you might need to link to Mesa).

Note that such a script does NOT use the ParaView animator and so you will be missing many of the great features. Nevertheless, if all you want to do is loop over input files, it gets the job done.

Kent
Pittsburgh Supercomputing Center

Antoine Dechaume wrote:
> I have a similar problem. I did a python-vtk script that animates time 
> dependent results and creates a movie. But doing visualization that way 
> is much much more cumbersome than using paraview. I have read the server 
> manager pdf file, but it only describes time manipulation with reader 
> that have built in time support.
> How could I set up paraview animation engine through python scripting, 
> without any reader that have time support ?
> 
> Antoine.
> 
> 
> On 25-Jun-08, at 8:42 AM, Kent Eschenberg wrote:
> 
>> Jaco,
>>
>> That would be easy to do using pvbatch and a batch script. The book 
>> and Wiki contain notes on such scripts which are written in Python. It 
>> can be tricky at first to create the visualizations but its quite 
>> powerful.
>>
>> I don't know whether pvbatch comes with the binary download. It is 
>> created  by default when you compile from source.
>>
>> Hey PV gurus: is there a "repository" of batch scripts somewhere? I 
>> have a few I could contribute.
>>
>> Kent
>> Pittsburgh Supercomputing Center
>>
>> L wrote:
>>> Hi, i am looking for one animation script who could take a lot of 
>>> files and then make one frame per each file. And then create the .avi 
>>> with those files. Is it possible? Does it already exist?
>>> Many thanks
>>> Jaco
>


More information about the ParaView mailing list