[Paraview] Animating In Batch

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Fri Feb 22 12:20:37 EST 2008


Hi Kent,

The "scene" is nothing but the vtkSMAnimationSceneProxy which was 
created in Paraview client when we were setting up the animation 
interactively. That proxy gets saved in the state will the entire scene 
setup.

This proxy has a "Play" property which can be called to play the 
animation. To save the animation images to a file you can use the 
following code snippet:

 > from paraview.servermanager import *
   ...
 > writer = vtkSMAnimationSceneImageWriter();
 > writer.SetFileName(filename);
 > writer.SetFrameRate(1);
 > writer.SetAnimationScene(scene.SMProxy);
 > if not writer.Save():
 >   raise exceptions.RuntimeError, "Saving of animation failed!"

Also, for general reference, one can look at 
"ParaView3/Utilities/VTKPythonWrapping/paraview/servermanager.py"
This file is the source for the servermanager python module and has 
example codes illustrating many of the python capabilities. Infact, the 
above code is borrowed from "AnimateReader" function implementation :).

Utkarsh

Kent Eschenberg wrote:
> Hi Utkarsh,
> 
> Thanks! That is a simple, elegant solution.
> 
> Your example doesn't seem to save the results to files. Obviously, this 
> is critical in batch since otherwise there is no point.
> 
> Does that happen at "scene.Play()"? Does it use the details (from the 
> state file, I would guess) provided when saving the animation 
> interactively?
> 
> Kent
> Pittsburgh Supercomputing Center
> 
> Utkarsh Ayachit wrote:
>> Hi Kent,
>>
>> Here's a sample plython script for doing what you want:
>>  > from paraview.servermanager import *
>>  > Connect()
>>  > LoadState("/tmp/animation.pvsm");
>>  > view = GetRenderView()
>>  > view.StillRender()
>>  > pxm = ProxyManager()
>>  > scene = pxm.GetProxy("animation", "AnimationScene1")
>>  > scene.Play()
>>
>> I've attached the animation.pvsm file that I used (created with CVS 
>> paraview). Currently (on CVS head), when I load this state I am 
>> getting some error messages. I'll look into those, but they don't 
>> affect the animation.
>>
>> Utkarsh
>>
>>
>> Kent Eschenberg wrote:
>>> There doesn't seem to be a concise guide to making animations in 
>>> batch so I could use some help with putting together the pieces.
>>>
>>> ===
>>> 1) Interactively, build the animation using a small version of the 
>>> data. It is NOT an animation over time.
>>>
>>> 2) Save the state then edit the state file to use the huge version of 
>>> the data.
>>>
>>> 3) Create a simple Python script that reads the state file.
>>>
>>> 4) Compiled ParaView 3.2.1 from source and set the flags to wrap it 
>>> in Python. This generate pvbatch.
>>>
>>> 5) Use pvbatch to run the Python script, producing files containing 
>>> the frames.
>>> ===
>>>
>>> But that doesn't seem to work. Is there a way to tell pvbatch to make 
>>> the animation? All that information is in the state file.
>>>
>>> Or do I have to painfully rebuild the animation as described in
>>> http://www.paraview.org/Wiki/images/f/f9/Servermanager2.pdf ?
>>>
>>> Kent
>>> Pittsburgh Supercomputing Center
>>> _______________________________________________
>>> ParaView mailing list
>>> ParaView at paraview.org
>>> http://www.paraview.org/mailman/listinfo/paraview
>>>
> 


More information about the ParaView mailing list