[Paraview] To create a snapshot from a given datafile and state, how to change the datafile filename of the state?

William Oquendo woquendo at gmail.com
Sat Apr 21 17:03:04 EDT 2012


Dear all,
I am currently able to visualize correctly in ParaView a .vtp file for each
time step of a simulation, and to print a screenshot for each. I want to do
that in batch, but I want to keep the same state for each one (view point,
filters applied, etc). I Have already saved the state into a .psvm file ,
and I tried to write a python script which, after being run by pvbatch,
will (hopefully) print the screenshots. But, unfortunately, it is not
working. I tried to change the filename in the state by processing search
and replace, but still is not working. For instance, it keeps working on
the first data input only. I use ParaView 3.14.0 in Snow Leopard. The
reader stuff (commented) is giving me errors. I am sure this is easy, but I
am overwhelmed with the large amount of info about python and paraview with
no reference to this issue. Please, please, any advice is greatly welcome,
and I am sorry if this has been answered previously (I looked at google and
the mailing list). Below is my script, which can also be found at
http://pastebin.com/UkDAcnHE .

#!/bin/python
import glob, string, os, commands
from paraview.simple import *

#help(servermanager)
# vtp files are inside the local subdir DISPLAY
files = (commands.getoutput("ls DISPLAY/data-*.vtp | grep -v
contacts")).split()

# process each file
for filename in files:
    fullfn = commands.getoutput("ls $PWD/" + filename).replace('/','\/')
    fn = filename.replace('DISPLAY/', '')
    #os.system("cp ../dem_git/addons/paraview_state.pvsm tmp.pvsm")
    os.system("cp ~/Desktop/state.pvsm tmp.pvsm")
    os.system("sed -i.bck 's/DATA.vtp/" + fullfn + "/1' tmp.pvsm") #
replace first intance with full path
    os.system("sed -i.bck 's/DATA.vtp/" + fullfn + "/1' tmp.pvsm") #
replace second intance with full path
    os.system("sed -i.bck 's/DATA.vtp/" + fn + "/1' tmp.pvsm") # replace
third with just the filename path
    servermanager.LoadState("tmp.pvsm")
    pm = servermanager.ProxyManager()
    #reader = pm.GetProxy("sources",fullfn)
    #reader.FileNames = fullfn
    #reader.FileNameChanged()
    #reader.UpdatePipeline()
    SetActiveView(GetRenderView())
    Render()
    WriteImage(fn + "-image.png")
    os.system("rm -f tmp.pvsm")
    #servermanager.Finalize()



Best regards / Cordialmente,

William-Fernando Oquendo
--------------------------
Este correo puede carecer de tildes o eñes debido al teclado.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120421/438aac6e/attachment-0001.htm>


More information about the ParaView mailing list