Advertisement
Guest User

Untitled

a guest
Apr 21st, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. #!/bin/python
  2. import glob, string, os, commands
  3. from paraview.simple import *
  4.  
  5. #help(servermanager)
  6. # vtp files are inside the local subdir DISPLAY
  7. files = (commands.getoutput("ls DISPLAY/data-*.vtp | grep -v contacts")).split()
  8.  
  9. # process each file
  10. for filename in files:
  11.     fullfn = commands.getoutput("ls $PWD/" + filename)
  12.     fn = filename.replace('DISPLAY/', '')
  13.     #os.system("cp ../dem_git/addons/paraview_state.pvsm tmp.pvsm")
  14.     os.system("cp ~/Desktop/state.pvsm tmp.pvsm")
  15.     os.system("sed -i.bck 's/DATA.vtp/" + fullfn.replace('/','\/') + "/1' tmp.pvsm") # replace first intance with full path
  16.     os.system("sed -i.bck 's/DATA.vtp/" + fullfn.replace('/','\/') + "/1' tmp.pvsm") # replace second intance with full path
  17.     os.system("sed -i.bck 's/DATA.vtp/" + fn + "/1' tmp.pvsm") # replace third with just the filename path
  18.     servermanager.LoadState("tmp.pvsm")
  19.     pm = servermanager.ProxyManager()
  20.     reader = pm.GetProxy('sources', fullfn)
  21.     reader.FileName = fullfn
  22.     reader.FileNameChanged()
  23.     reader.UpdatePipeline()
  24.  
  25.     view = servermanager.GetRenderView()
  26.     SetActiveView(view)
  27.     view.StillRender()
  28.  
  29.     WriteImage(filename.replace(".vtp", ".png"))
  30.     os.system("rm -f tmp.pvsm")
  31.     os.system("rm -f tmp.pvsm.bck")
  32.  
  33.     Delete(reader)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement