[prev in list] [next in list] [prev in thread] [next in thread]
List: paraview
Subject: Re: [Paraview] Scripting Common UI Tasks for Opening Files
From: Christian Richter <christian.richter () ovgu ! de>
Date: 2012-10-22 18:38:37
Message-ID: 508592AD.50507 () ovgu ! de
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
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@kitware.com
> <mailto:andy.bauer@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@gmail.com <mailto:aj.guillon@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
[Attachment #5 (text/html)]
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi<br>
<br>
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)<br>
<br>
Then the Representation-Style is set.<br>
<br>
If you hit the Button again the last timestep is loaded (I use
this script while the simulation is running)<br>
<br>
Greez,<br>
CR<br>
<br>
Am 22.10.2012 20:28, schrieb Adrien Guillon:<br>
</div>
<blockquote
cite="mid:CAKMAvExVRgJSS1Nq+uh5gk1ZsBT6_1-F_kFhui96oK4bT+n56A@mail.gmail.com"
type="cite">Hi,<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
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:<br>
<br>
X_f1_*.vtp<br>
X_f2_*.vtu<br>
X_f3_*.vtu<br>
<br>
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.<br>
<br>
AJ<br>
<br>
<div class="gmail_quote">On Sun, Oct 21, 2012 at 2:26 PM, Andy
Bauer <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:andy.bauer@kitware.com" \
target="_blank">andy.bauer@kitware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
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. <br>
<br>
You could also create a state file (File->Save State) which
may also accomplish what you're looking for. <br>
<br>
If either of those don't work as expected and/or desired, I
would recommend emailing back the list with specific problems.<span
class="HOEnZb"><font color="#888888"><br>
<br>
Andy<br>
<br>
</font></span>
<div class="gmail_quote">
<div>
<div class="h5">On Sun, Oct 21, 2012 at 12:49 PM, Adrien
Guillon <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:aj.guillon@gmail.com" \
target="_blank">aj.guillon@gmail.com</a>></span> wrote:<br>
</div>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div class="h5">
Hi everyone,<br>
<br>
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.<br>
<br>
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.<br>
<br>
Any suggestions on how to accomplish some automation?<br>
<br>
AJ<br>
<br>
</div>
</div>
<div class="im">_______________________________________________<br>
Powered by <a moz-do-not-send="true"
href="http://www.kitware.com" \
target="_blank">www.kitware.com</a><br> <br>
Visit other Kitware open-source projects at <a
moz-do-not-send="true"
href="http://www.kitware.com/opensource/opensource.html"
target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the ParaView
Wiki at: <a moz-do-not-send="true"
href="http://paraview.org/Wiki/ParaView"
target="_blank">http://paraview.org/Wiki/ParaView</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a moz-do-not-send="true"
href="http://www.paraview.org/mailman/listinfo/paraview"
target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
<br>
</div>
</blockquote>
</div>
<br>
</blockquote>
</div>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" \
href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" \
href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the ParaView Wiki at: <a \
class="moz-txt-link-freetext" \
href="http://paraview.org/Wiki/ParaView">http://paraview.org/Wiki/ParaView</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" \
href="http://www.paraview.org/mailman/listinfo/paraview">http://www.paraview.org/mailman/listinfo/paraview</a>
</pre>
</blockquote>
<br>
</body>
</html>
["update.py" (text/plain)]
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()
_______________________________________________
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic