[Paraview] Visibility Animation using Python Batches

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Fri Apr 16 01:04:28 EDT 2010


Here is an updated version of your script with inline comments. That
should get you started.

-----------------------
from paraview.simple import *

# Create a view first!!!
CreateRenderView()

scene = servermanager.animation.AnimationScene()
scene.ViewModules = [GetActiveView()]
pts = [[15,15,15],[10,10,10],[5,5,5],[0,0,0],[-5,-5,-5],[-10,-10,-10],[-15,-15,-15]]
spheres=[]
cues=[]
# the time for the animation cue are in relation to the StartTime and EndTime
# for the scene which by default is 0.0 and 1.0 respectively, so we scale the
# KeyTime values for key frames accordingly
ts=1.0/len(pts)
for i in range(len(pts)):
       # Create the sphere
       spheres.append(Sphere(Center=pts[i], Radius=2,ThetaResolution=5))
       repr = Show(spheres[i])
       repr.DiffuseColor=[0.5,0.8,0]
       # Animate
       cues.append(servermanager.animation.KeyFrameAnimationCue())
       # Visibility is a property on the representation, not the sphere itself.
       cues[i].AnimatedProxy = repr
       cues[i].AnimatedPropertyName = "Visibility"
       keyf0 = servermanager.animation.CompositeKeyFrame()
       keyf0.KeyTime = 0
       keyf0.KeyValues=0
       keyf1 = servermanager.animation.CompositeKeyFrame()
       keyf1.KeyTime=i*ts
       keyf1.KeyValues=1
       cues[i].KeyFrames=[keyf0,keyf1]
# Doing this here so that the camera is setup correctly to view all the spheres
ResetCamera()

scene.Cues = cues
# set the number of frames in the animation.
scene.NumberOfFrames = 100
scene.PlayMode = "Sequence"
scene.Play()
----------------------------------------------





On Thu, Apr 15, 2010 at 9:58 PM, Maxime Taquet
<maxime.taquet at uclouvain.be> wrote:
> Dear all,
>
> Sorry if this question sounds dummy but I'm really new to Paraview and Python. I would like to realize and save an animation that displays tens of sphere sequentially (i.e. the spheres appear one at a time). Since I have a lot of them, I would like to do it using Python commands. However, it does not seem to work at all for me. Here is what I tried:
>
> scene = servermanager.animation.AnimationScene()
> scene.ViewModules = [GetActiveView()]
> pts = [[15,15,15],[10,10,10],[5,5,5],[0,0,0],[-5,-5,-5],[-10,-10,-10],[-15,-15,-15]]
> spheres=[]
> cues=[]
> ts=1
> for i in range(len(pts)):
>        # Create the sphere
>        spheres.append(Sphere(Center=pts[i], Radius=2,ThetaResolution=5))
>        Show(spheres[i])
>        r = GetRepresentation()
>        r.DiffuseColor=[0.5,0.8,0]
>        # Animate
>        cues.append(servermanager.animation.KeyFrameAnimationCue())
>        cues[i].AnimatedProxy = GetActiveSource()
>        cues[i].AnimatedPropertyName = "Visibility"
>        keyf0 = servermanager.animation.CompositeKeyFrame()
>        keyf0.KeyTime = 0
>        keyf0.KeyValues=0
>        keyf1 = servermanager.animation.CompositeKeyFrame()
>        keyf1.KeyTime=i*ts
>        keyf1.KeyValues=1
>        cues[i].KeyFrames=[keyf0,keyf1]
>
> scene.Cues = cues
> scene.Play()
>
> and I get this error:
>
> ERROR: In /Users/partyd/Dashboards/MyTests/ParaView-3-8-0/ParaView3/Servers/ServerManager/vtkSMBooleanKeyFrameProxy.cxx, line 48
> vtkSMBooleanKeyFrameProxy (0x143059ee0): Cue does not have domain or property set!
>
>
> If there's a simple GUI way to do it, I'd be blessed too of course but I don't want to do it for each point separately. In the example, above, I just set pts to some arbitrary values but in my case I really have tens of points.
>
> Thank you a lot in advance!
>
> Maxime
> _______________________________________________
> 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