Reputation: 41
I'm trying to write a Python script for Paraview that will create a .png or .pdf screenshot file with multiple views in it. The emphasis here being the MULTIPLE VIEWS part. To be clear, I have three different windows in my Paraview display: one showing the model viewed in the XZ plane, one in the XY plane and one in the YZ plane. I'm trying to use a python script to create a single file showing all three of these views. This can be done manually by clicking File->Save Screenshot
and then unchecking the Save only selected view
button. I need to do this several hundred times, so clearly a script is the way to go.
I've tried using the "Start trace" option to see how this operation works, but the code it produces seems incomplete:
try: paraview.simple
except: from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()
RenderView1 = GetRenderView()
RenderView2 = GetRenderViews()[1]
RenderView3 = GetRenderViews()[2]
WriteImage(r'E:\TestFolder\TestFile_00.png', view=RenderView1)
WriteImage(r'E:\TestFolder\TestFile_01.png', view=RenderView2)
WriteImage(r'E:\TestFolder\TestFile_02.png', view=RenderView3)
Render()
When I run something similar to this it just produces three separate .png files, one for each view. Maybe these are meant to be temporary files that Paraview combines to make the finished product, but I have no idea how to combine them.
Does anyone have any experience with this problem? I've scoured the internet and the Paraview documentation, but the only examples I can find have a single view only. Any help would be much appreciated.
I'm using Paraview 3.12.0 32-bit on Windows XP
Upvotes: 2
Views: 3897
Reputation: 1522
Starting with ParaView 4.2, this will directly supported as follows:
# Get the layout/tab for the active view.
aLayout = GetLayout()
SaveScreenshot("AllViewsImage.png", layout=aLayout)
You can also use Tools|Start Trace and try to save the screenshot out to get the commands to use.
Upvotes: 5
Reputation: 21
I have the same problem. The workaround is to use convert command. Here is the example script:
for i in range(len(GetRenderViews())) :
RenderView = GetRenderViews()[i]
WriteImage("tmp_"+str(i)+".png",view=RenderView)
commands.getoutput("convert -border 1x1 -append tmp_*.png tmp.png")
I hope this will help.
Upvotes: 2