[Paraview] Scripting Common UI Tasks for Opening Files
Christian Richter
christian.richter at ovgu.de
Mon Oct 22 14:38:37 EDT 2012
Hi
for time-series data I'm using the attached script. First it looks in
the 'post'-folder and sort the files by number naturally. After that it
gives the sorted array to the readerclass (change this for your reader
as in the traced macro you got from the macro tool)
Then the Representation-Style is set.
If you hit the Button again the last timestep is loaded (I use this
script while the simulation is running)
Greez,
CR
Am 22.10.2012 20:28, schrieb Adrien Guillon:
> Hi,
>
> So this doesn't quite work. The problem is that the generated script
> seems to hard-code particular filenames, rather than say just looking
> at the order of the pipeline. Given that we have to open several
> files at the same time, and then arrange a visualization of simulation
> results, this isn't quite what we want.
>
> I was unaware of the macro feature, so I might be able to investigate
> a bit further to write a python macro that does what we want.
>
> I considered writing a script to generate a state file automatically
> for a given set of filenames. I'm not sure if this is the best option
> or not. It depends upon the portability of these files from version
> to version, and the dependency upon particular files.
>
> In particular, we have several file types which particular features of
> results. So, for instance, we might have for simulation run X, and
> features f_j:
>
> X_f1_*.vtp
> X_f2_*.vtu
> X_f3_*.vtu
>
> We need to open these files and make some basic adjustments so that we
> have a good idea of what is happening in the simulation.
>
> AJ
>
> On Sun, Oct 21, 2012 at 2:26 PM, Andy Bauer <andy.bauer at kitware.com
> <mailto:andy.bauer at kitware.com>> wrote:
>
> If you're using the python trace (under Tools->Start Trace/Stop
> Trace) you can create a python script that should mimic what
> you're doing in the GUI. After you stop the trace you have the
> option of saving it as a macro which will then allow you to click
> on a widget in the GUI to replay those actions.
>
> You could also create a state file (File->Save State) which may
> also accomplish what you're looking for.
>
> If either of those don't work as expected and/or desired, I would
> recommend emailing back the list with specific problems.
>
> Andy
>
> On Sun, Oct 21, 2012 at 12:49 PM, Adrien Guillon
> <aj.guillon at gmail.com <mailto:aj.guillon at gmail.com>> wrote:
>
> Hi everyone,
>
> We have simulation results that we frequently visualize in the
> same way. We construct a specific pipeline, visualize some
> parts as wireframe, set a color scheme, and so on.
> Unfortunately, this is done manually at the moment, which
> means that just opening simulation results can take a few
> minutes of clicking around. I'm looking to script this.
>
> Is there a way to script the UI so that it opens a number of
> given files, and adjusts features automatically? My
> investigations into Python scripting with Paraview suggest
> that it cannot directly control the UI, instead it does
> analysis using Paraview.
>
> Any suggestions on how to accomplish some automation?
>
> AJ
>
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
>
>
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/mailman/listinfo/paraview
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20121022/27585a7e/attachment.htm>
-------------- next part --------------
from paraview.simple import *
import glob
folder="post/dump*.liggghts"
stlfolder="post/dump*.stl"
def try_int(s):
"Convert to integer if possible."
try: return int(s)
except: return s
def natsort_key(s):
"Used internally to get a tuple by which s is sorted."
import re
return map(try_int, re.findall(r'(\d+|\D+)', s))
def natcmp(a, b):
"Natural string comparison, case sensitive."
return cmp(natsort_key(a), natsort_key(b))
def natcasecmp(a, b):
"Natural string comparison, ignores case."
return natcmp(a.lower(), b.lower())
# Find the source object
if (FindSource("liggghts_dump")==None): #create 1st time
files = glob.glob(folder)
files.sort(natcasecmp)
xreader=liggghts_Reader(guiName="liggghts_dump", FileNames=files)
#xreader.FileNames=files
SetDisplayProperties(xreader, Representation="Point Sprite")
DataRepresentation1 = Show()
DataRepresentation1.PointSpriteDefaultsInitialized = 1
DataRepresentation1.Texture = []
DataRepresentation1.RadiusTransferFunctionEnabled = 1
DataRepresentation1.RadiusMode = 'Scalar'
DataRepresentation1.Representation = 'Point Sprite'
DataRepresentation1.RadiusArray = [None, 'radius']
DataRepresentation1.RadiusIsProportional = 1
else:
files = glob.glob(folder) #update file list
files.sort(natcasecmp)
xreader.FileNames=files
RenderView1 = GetRenderView()
AnimationScene1 = GetAnimationScene()
end=len(files)-1
RenderView1.ViewTime = end
AnimationScene1.AnimationTime = end
Render()
# Find the source object
if (FindSource("stl_dump")==None): #create 1st time
files = glob.glob(stlfolder)
files.sort(natcasecmp)
stlreader=STLReader(guiName="stl_dump", FileNames=files)
else:
files = glob.glob(stlfolder) #update file list
files.sort(natcasecmp)
stlreader.FileNames=files
RenderView1 = GetRenderView()
AnimationScene1 = GetAnimationScene()
end=len(files)-1
RenderView1.ViewTime = end
AnimationScene1.AnimationTime = end
Render()
More information about the ParaView
mailing list