[Paraview] Import Preset color scale only if not already loaded

postgurke at web.de postgurke at web.de
Thu Sep 8 03:52:03 EDT 2016


Hello All

I haven't been able to find a solution for this, so maybe someone can give me a
hint...:
I am loading data via a python script into ParaView (5.0) and want to color it
with a specific color scale. I can load this scale with the script and apply the
coloring as desired but if the scale is already loaded, it will then be loaded
twice (or more). What I would like to do is check if the scale is loaded and if
yes apply it, if not first load and then apply.
I tought, that try/except would be my friend here, but applying a preset that is
not loaded doesn't throw an error but uses the default Cool to Warm scale
instead... What is also somewhat strange: if I had the specific scale loaded in
a ParaView session, but removed it from the list of presets, ParaView can
somehow remember it nonetheless and shows the data correctly (i.e. not with the
Cool to Warm scale but the specific one). 
Does somebody have an idea how I can avoid having the specific scale loaded
multiple times and still have the python script always producing the correct
visualization of the data set?

Here is the code I was trying:
...
zLUT=GetColorTransferFunction(ts)
try: 
	zLUT.ApplyPreset(colorname,False)
except: 
	ImportPresets(filename=colorname+'.json')
	zLUT.ApplyPreset(colorname,False)
...


Thank you very much! 
Venke


More information about the ParaView mailing list