我目前能夠在ParaView .vtp文件中正確顯示模擬的每個時間步驟,併爲每個步驟打印截圖。我想批量做到這一點,但我想保持每個人的相同狀態(視點,過濾器應用等)。我已經將狀態保存到一個.psvm文件中,並且我嘗試編寫一個python腳本,在由pvbatch運行後,將(希望)打印屏幕截圖。但不幸的是,它不起作用。我試圖通過處理狀態文件並執行搜索和替換來更改狀態中的文件名,但仍然無法正常工作。例如,即使當前文件不同(即使GetSources()顯示始終增加的源列表),它也會保持僅繪製第一個數據輸入。我在Snow Leopard中使用ParaView 3.14.0。我確信這很容易,但是我對大量的關於python和paraview的信息感到不知所措,而沒有提到這個特殊情況。請,請任何意見,非常歡迎,如果這已被回答以前(我看着谷歌,paraview郵件列表,並在這裏),我很抱歉。以下是我的腳本,它也可以在http://pastebin.com/4xiLNrS0找到。此外,您可以在http://goo.gl/XjPpE中找到一些示例文件和狀態。在Paraview中,如何更改狀態的數據文件文件名以從給定的數據文件和狀態創建快照?
#!/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)
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.replace('/','\/') + "/1' tmp.pvsm") # replace first intance with full path
os.system("sed -i.bck 's/DATA.vtp/" + fullfn.replace('/','\/') + "/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.FileName = fullfn
reader.FileNameChanged()
reader.UpdatePipeline()
view = servermanager.GetRenderView()
SetActiveView(view)
view.StillRender()
WriteImage(filename.replace(".vtp", ".png"))
os.system("rm -f tmp.pvsm")
os.system("rm -f tmp.pvsm.bck")
Delete(reader)
@Chris:非常感謝,我忘了做那件重要的事情。我剛剛做到了。編輯:我沒有接受任何答案,但我目前正在使用:) – iluvatar 2012-04-25 11:44:36