Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 21st, 2012  |  syntax: Python  |  size: 1.28 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)
clone this paste RAW Paste Data