[Paraview] Save animation using python script
Michael Martinec
michael.martinec at stud.unibas.ch
Mon Aug 13 07:37:28 EDT 2007
Hi
I tried but still have problems with the script. How can I save
animations to *.avi using scripts? What do I have to apply my script to
save animations? I have a script that imports the timesteps (in previous
mail). Then i wrote something like this:
animproxy = paraview.CreateProxy("animation", "AnimationScene",
"animation", "PVAnimationScene1")
animproxy.SetStartTime( 0 )
animproxy.SetEndTime( 8 )
animproxy.SetFrameRate( 10 )
animproxy.UpdateVTKObjects()
anim = paraview.vtkSMAnimationSceneImageWriter()
anim.SetFileName( "/home/miki/Desktop/testAVI.avi" )
anim.SetFrameRate( 10 )
anim.SetAnimationScene( animproxy )
anim.Save()
But it doesn't seem to work. It doesn't accept animproxy as a parameter
in SetAnimationScene.
Thankyou for helping!
*Michael
-------- Original Message --------
Subject: Re: Re: Save animation using python script (Utkarsh Ayachit)
Date: Fri, 27 Jul 2007 14:00:30 +0200
From: Michael Martinec <michael.martinec at stud.unibas.ch>
To: paraview at paraview.org
References: <20070725160021.AF3741D8A6A at public.kitware.com>
I need a little more help on this one. Could you give me an example
implementation? What is my animation scene proxy? Below is my xml file
and script (made using dump script from Jordi) for which some of you
have asked.
*.pvd:
<?xml version="1.0"?>
<VTKFile type="Collection" version="0.1" byte_order="LittleEndian"
compressor="vtkZLibDataCompressor">
<Collection>
<DataSet timestep="0" file="000000-solution.vtu"/>
...
<DataSet timestep="130" file="000130-solution.vtu"/>
</Collection>
</VTKFile>
*.py:
#!/usr/local/bin/pvpython
# <script>.py
import paraview
if paraview.ActiveConnection == None : CONSOLE = True
else : CONSOLE = False
if CONSOLE: # init Conn and
RenderM
paraview.ActiveConnection = paraview.Connect()
renderM = paraview.CreateRenderWindow()
else:
renders = paraview.pyProxyManager().GetProxiesInGroup("multirendermodule",
paraview.ActiveConnection)
renderM = renders.values()[0].GetRenderModules()[0]
# batchAnimpvd
batchAnimpvd = paraview.CreateProxy("sources", "PVDReader", "sources",
"batchAnim.pvd")
batchAnimpvd.SetFileName(
"/home/miki/uni/bachelor/solutions/batchAnim.pvd" )
batchAnimpvd.SetTimestepValues( 0, 1, 2, 3, 4, 5, 6, 7, 8 )
batchAnimpvd.UpdateVTKObjects()
# tissuesvtu
tissuesvtu = paraview.CreateProxy("sources",
"XMLUnstructuredGridReader", "sources", "tissues.vtu")
tissuesvtu.SetCellArrayInfo( "tissues", "1" )
tissuesvtu.SetCellArrayStatus( "tissues", "1" )
tissuesvtu.SetFileName( "/home/miki/uni/bachelor/tissues.vtu" )
# tissuesvtu.SetPointArrayInfo( "" )
# tissuesvtu.SetPointArrayStatus( "" )
tissuesvtu.UpdateVTKObjects()
# cutFunction
cutFunction = paraview.CreateProxy("implicit_functions", "Plane",
"pq_helper_proxies.348", "CutFunction")
cutFunction.SetInput( batchAnimpvd )
cutFunction.SetNormal( 0, 1, 0 )
cutFunction.SetOffset( 0 )
cutFunction.SetOrigin( -0.006899, 0.005319, -0.0310375 )
cutFunction.UpdateVTKObjects()
# v1tissues
v1tissues = paraview.CreateProxy("lookup_tables", "PVLookupTable",
"lookup_tables", "1.tissues")
v1tissues.SetColorSpace( 1 )
v1tissues.SetDiscretize( 1 )
v1tissues.SetHSVWrap( 0 )
v1tissues.SetLockScalarRange( 0 )
v1tissues.SetNumberOfTableValues( 256 )
v1tissues.SetRGBPoints( 1, 0, 0, 1, 7, 1, 0, 0 )
v1tissues.SetScalarRangeInitialized( 1 )
v1tissues.SetUseLogScale( 0 )
v1tissues.SetVectorComponent( 0 )
v1tissues.SetVectorMode( 0 )
v1tissues.UpdateVTKObjects()
#
scalarOpacityFunction
scalarOpacityFunction = paraview.CreateProxy("piecewise_functions",
"PiecewiseFunction", "pq_helper_proxies.176", "ScalarOpacityFunction")
scalarOpacityFunction.SetPoints( 0, 0, 1, 1 )
scalarOpacityFunction.UpdateVTKObjects()
# threshold
threshold = paraview.CreateProxy("filters", "Threshold", "sources",
"Threshold1")
threshold.SetAllScalars( 1 )
threshold.SetInput( tissuesvtu )
threshold.SetSelectInputScalars( "tissues", "1" )
threshold.SetThresholdBetween( 3.58, 4.42 )
threshold.UpdateVTKObjects()
#
scalarOpacityFunction
scalarOpacityFunction = paraview.CreateProxy("piecewise_functions",
"PiecewiseFunction", "pq_helper_proxies.268", "ScalarOpacityFunction")
scalarOpacityFunction.SetPoints( 0, 0, 1, 1 )
scalarOpacityFunction.UpdateVTKObjects()
#
scalarOpacityFunction
scalarOpacityFunction = paraview.CreateProxy("piecewise_functions",
"PiecewiseFunction", "pq_helper_proxies.76", "ScalarOpacityFunction")
scalarOpacityFunction.SetPoints( 25.4353, 0, 46.7218, 1 )
scalarOpacityFunction.UpdateVTKObjects()
# v1y
v1y = paraview.CreateProxy("lookup_tables", "PVLookupTable",
"lookup_tables", "1.y")
v1y.SetColorSpace( 1 )
v1y.SetDiscretize( 1 )
v1y.SetHSVWrap( 0 )
v1y.SetLockScalarRange( 0 )
v1y.SetNumberOfTableValues( 256 )
v1y.SetRGBPoints( 25.4353, 0, 0, 1, 46.7218, 1, 0, 0 )
v1y.SetScalarRangeInitialized( 1 )
v1y.SetUseLogScale( 0 )
v1y.SetVectorComponent( 0 )
v1y.SetVectorMode( 0 )
v1y.UpdateVTKObjects()
#
scalarOpacityFunction
scalarOpacityFunction = paraview.CreateProxy("piecewise_functions",
"PiecewiseFunction", "pq_helper_proxies.366", "ScalarOpacityFunction")
scalarOpacityFunction.SetPoints( 0, 0, 1, 1 )
scalarOpacityFunction.UpdateVTKObjects()
# cut
cut = paraview.CreateProxy("filters", "Cut", "sources", "Cut1")
cut.SetContourValues( 0 )
cut.SetCutFunction( cutFunction )
cut.SetInput( batchAnimpvd )
# cut.SetInputBounds( "" )
cut.UpdateVTKObjects()
# dataDisplay2
dataDisplay2 = paraview.CreateDisplay(tissuesvtu, renderM)
dataDisplay2.SetCacheUpdate( 0, -1 )
dataDisplay2.SetInput( tissuesvtu )
dataDisplay2.SetLODResolution( 50 )
dataDisplay2.SetRepresentation( 2 )
dataDisplay2.SetUpdateTime( 0 )
dataDisplay2.SetVisibility( 0 )
dataDisplay2.SetAmbientColor( 1, 1, 1 )
# dataDisplay2.SetClippingPlanes( "" )
dataDisplay2.SetColor( 1, 1, 1 )
dataDisplay2.SetColorArray( "tissues" )
dataDisplay2.SetColorMode( 1 )
dataDisplay2.SetDiffuseColor( 1, 1, 1 )
dataDisplay2.SetForceStrips( 0 )
dataDisplay2.SetImmediateModeRendering( 0 )
dataDisplay2.SetInterpolateScalarsBeforeMapping( 1 )
dataDisplay2.SetInterpolation( 1 )
dataDisplay2.SetLineWidth( 1 )
dataDisplay2.SetLookupTable( v1tissues )
dataDisplay2.SetMapScalars( 1 )
# dataDisplay2.SetMaterial( "" )
dataDisplay2.SetNumberOfSubPieces( 1 )
dataDisplay2.SetOpacity( 1 )
dataDisplay2.SetOrientation( 0, 0, 0 )
dataDisplay2.SetOrigin( 0, 0, 0 )
dataDisplay2.SetPickable( 1 )
dataDisplay2.SetPointSize( 5 )
dataDisplay2.SetPosition( 0, 0, 0 )
# dataDisplay2.SetRenderModuleHelper( none )
dataDisplay2.SetSaveCacheOnCacheUpdate( 1 )
dataDisplay2.SetScalarMode( 4 )
dataDisplay2.SetScalarOpacityFunction( scalarOpacityFunction )
dataDisplay2.SetScalarOpacityUnitDistance( 1 )
dataDisplay2.SetScalarVisibility( 1 )
dataDisplay2.SetScale( 1, 1, 1 )
dataDisplay2.SetShading( 0 )
dataDisplay2.SetSpecularColor( 1, 1, 1 )
dataDisplay2.SetSpecularPower( 100 )
dataDisplay2.SetUseLookupTableScalarRange( 1 )
dataDisplay2.SetUseStrips( 0 )
dataDisplay2.UpdateVTKObjects()
# dataDisplay3
dataDisplay3 = paraview.CreateDisplay(threshold, renderM)
dataDisplay3.SetCacheUpdate( 0, -1 )
dataDisplay3.SetInput( threshold )
dataDisplay3.SetLODResolution( 50 )
dataDisplay3.SetRepresentation( 2 )
dataDisplay3.SetUpdateTime( 0 )
dataDisplay3.SetVisibility( 1 )
dataDisplay3.SetAmbientColor( 1, 1, 1 )
# dataDisplay3.SetClippingPlanes( "" )
dataDisplay3.SetColor( 1, 1, 1 )
dataDisplay3.SetColorArray( "tissues" )
dataDisplay3.SetColorMode( 1 )
dataDisplay3.SetDiffuseColor( 1, 1, 1 )
dataDisplay3.SetForceStrips( 0 )
dataDisplay3.SetImmediateModeRendering( 0 )
dataDisplay3.SetInterpolateScalarsBeforeMapping( 1 )
dataDisplay3.SetInterpolation( 1 )
dataDisplay3.SetLineWidth( 1 )
dataDisplay3.SetLookupTable( v1tissues )
dataDisplay3.SetMapScalars( 1 )
# dataDisplay3.SetMaterial( "" )
dataDisplay3.SetNumberOfSubPieces( 1 )
dataDisplay3.SetOpacity( 0.2 )
dataDisplay3.SetOrientation( 0, 0, 0 )
dataDisplay3.SetOrigin( 0, 0, 0 )
dataDisplay3.SetPickable( 1 )
dataDisplay3.SetPointSize( 5 )
dataDisplay3.SetPosition( 0, 0, 0 )
# dataDisplay3.SetRenderModuleHelper( none )
dataDisplay3.SetSaveCacheOnCacheUpdate( 1 )
dataDisplay3.SetScalarMode( 4 )
dataDisplay3.SetScalarOpacityFunction( scalarOpacityFunction )
dataDisplay3.SetScalarOpacityUnitDistance( 1 )
dataDisplay3.SetScalarVisibility( 1 )
dataDisplay3.SetScale( 1, 1, 1 )
dataDisplay3.SetShading( 0 )
dataDisplay3.SetSpecularColor( 1, 1, 1 )
dataDisplay3.SetSpecularPower( 100 )
dataDisplay3.SetUseLookupTableScalarRange( 1 )
dataDisplay3.SetUseStrips( 0 )
dataDisplay3.UpdateVTKObjects()
# dataDisplay
dataDisplay = paraview.CreateDisplay(batchAnimpvd, renderM)
dataDisplay.SetCacheUpdate( 0, -1 )
dataDisplay.SetInput( batchAnimpvd )
dataDisplay.SetLODResolution( 50 )
dataDisplay.SetRepresentation( 4 )
dataDisplay.SetUpdateTime( 0 )
dataDisplay.SetVisibility( 1 )
dataDisplay.SetAmbientColor( 1, 1, 1 )
# dataDisplay.SetClippingPlanes( "" )
dataDisplay.SetColor( 1, 1, 1 )
dataDisplay.SetColorArray( "y" )
dataDisplay.SetColorMode( 1 )
dataDisplay.SetDiffuseColor( 1, 1, 1 )
dataDisplay.SetForceStrips( 0 )
dataDisplay.SetImmediateModeRendering( 0 )
dataDisplay.SetInterpolateScalarsBeforeMapping( 1 )
dataDisplay.SetInterpolation( 1 )
dataDisplay.SetLineWidth( 1 )
dataDisplay.SetLookupTable( v1y )
dataDisplay.SetMapScalars( 1 )
# dataDisplay.SetMaterial( "" )
dataDisplay.SetNumberOfSubPieces( 1 )
dataDisplay.SetOpacity( 1 )
dataDisplay.SetOrientation( 0, 0, 0 )
dataDisplay.SetOrigin( 0, 0, 0 )
dataDisplay.SetPickable( 1 )
dataDisplay.SetPointSize( 5 )
dataDisplay.SetPosition( 0, 0, 0 )
# dataDisplay.SetRenderModuleHelper( none )
dataDisplay.SetSaveCacheOnCacheUpdate( 1 )
dataDisplay.SetScalarMode( 3 )
dataDisplay.SetScalarOpacityFunction( scalarOpacityFunction )
dataDisplay.SetScalarOpacityUnitDistance( 1 )
dataDisplay.SetScalarVisibility( 1 )
dataDisplay.SetScale( 1, 1, 1 )
dataDisplay.SetShading( 0 )
dataDisplay.SetSpecularColor( 1, 1, 1 )
dataDisplay.SetSpecularPower( 100 )
dataDisplay.SetUseLookupTableScalarRange( 1 )
dataDisplay.SetUseStrips( 0 )
dataDisplay.UpdateVTKObjects()
# dataDisplay4
dataDisplay4 = paraview.CreateDisplay(cut, renderM)
dataDisplay4.SetCacheUpdate( 0, -1 )
dataDisplay4.SetInput( cut )
dataDisplay4.SetLODResolution( 50 )
dataDisplay4.SetRepresentation( 2 )
dataDisplay4.SetUpdateTime( 0 )
dataDisplay4.SetVisibility( 1 )
dataDisplay4.SetAmbientColor( 1, 1, 1 )
# dataDisplay4.SetClippingPlanes( "" )
dataDisplay4.SetColor( 1, 1, 1 )
dataDisplay4.SetColorArray( "y" )
dataDisplay4.SetColorMode( 1 )
dataDisplay4.SetDiffuseColor( 1, 1, 1 )
dataDisplay4.SetForceStrips( 0 )
dataDisplay4.SetImmediateModeRendering( 0 )
dataDisplay4.SetInterpolateScalarsBeforeMapping( 1 )
dataDisplay4.SetInterpolation( 1 )
dataDisplay4.SetLineWidth( 1 )
dataDisplay4.SetLookupTable( v1y )
dataDisplay4.SetMapScalars( 1 )
# dataDisplay4.SetMaterial( "" )
dataDisplay4.SetNumberOfSubPieces( 1 )
dataDisplay4.SetOpacity( 1 )
dataDisplay4.SetOrientation( 0, 1, 0 )
dataDisplay4.SetOrigin( 0, 0, 0 )
dataDisplay4.SetPickable( 1 )
dataDisplay4.SetPointSize( 5 )
dataDisplay4.SetPosition( 0, 0, 0 )
# dataDisplay4.SetRenderModuleHelper( none )
dataDisplay4.SetSaveCacheOnCacheUpdate( 1 )
dataDisplay4.SetScalarMode( 3 )
dataDisplay4.SetScalarOpacityFunction( scalarOpacityFunction )
dataDisplay4.SetScalarOpacityUnitDistance( 1 )
dataDisplay4.SetScalarVisibility( 1 )
dataDisplay4.SetScale( 1, 1, 1 )
dataDisplay4.SetShading( 0 )
dataDisplay4.SetSpecularColor( 1, 1, 1 )
dataDisplay4.SetSpecularPower( 100 )
dataDisplay4.SetUseLookupTableScalarRange( 1 )
dataDisplay4.SetUseStrips( 0 )
dataDisplay4.UpdateVTKObjects()
if CONSOLE:
renderM.ResetCamera()
renderM.StillRender()
raw_input("Enter to finish")
#import time ; time.sleep(2)
> Utkarsh wrote:
>
>
> You'll have to create a "vtkSMAnimationSceneImageWriter" object to write
> an animation out. This is not a proxy. So simply create the writer
> object, set properties such as "FrameRate", "FileName", "Magnification"
> on it. Also set the "AnimationScene" to point to the animation scene
> proxy, and the call "Save". That should write the animation out.
>
> Utkarsh.
>
> Michael Martinec wrote:
>
>> Hi
>>
>> I have created a *.pvd xml file which loads timestep and *.vtu file data
>> into paraview.
>> From paraview i can then save the animation to a *.avi file nicely. I
>> could also create a python script which loads the *.pvd file and brings
>> me to the state before saving it as an animation. But I do not know how
>> to save the animation from the script. What do I have to apply to the
>> python script?
>>
>> Regards and thanx for helping!
>> *Michael
>>
>>
>> _______________________________________________
>> ParaView mailing list
>> ParaView at paraview.org
>> http://www.paraview.org/mailman/listinfo/paraview
>>
>>
>
>
> ------------------------------
>
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
>
>
> End of ParaView Digest, Vol 39, Issue 44
> ****************************************
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/paraview/attachments/20070813/a4fa650f/attachment.html
More information about the ParaView
mailing list