[Paraview] Update Button Work-a-round
Christian Richter
christian.richter at ovgu.de
Thu Nov 10 09:46:37 EST 2011
Hello All,
Because there is no Update Button available in Paraview I made a little
Py-script to reload the filenames in FileSeriesReader for my own reader
class (should work with other reader classes too).
Now, everytime I hit the button, the new FileNameList is updatet, and
the last available File is shown. (I love the PointSprite Plugin, if you
need other representations change some lines).
Now there is on wish left: how to run this script periodicaly every n
seconds OR everytime thereis a new file in the solution directory.
I tried python Threading/Timer but they seems not to work in
Paraview-Python Console.
Is there any possibility to trigger a python script from inside Paraview ?
I'm not a Python Coder, so maybe I did not try every method to make a
loop which does not deadlock :-)
Here is the script to update a files-series-reader:
|
from paraview.simple import *
import glob|
folder="post/*.liggghts"
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
files = glob.glob(folder)
files.sort(natcasecmp)
xreader=liggghts_Reader(guiName="liggghts_dump")
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)
files.sort(natcasecmp)
xreader.FileNames=files ##update
RenderView1 = GetRenderView()
AnimationScene1 = GetAnimationScene()
end=len(files)-1
RenderView1.ViewTime = end
AnimationScene1.AnimationTime = end
Render()
Best wishes,
Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20111110/15d522fc/attachment-0001.htm>
More information about the ParaView
mailing list