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

postgurke at web.de postgurke at web.de
Thu Sep 8 08:41:30 EDT 2016


... not just something like it, it is exactly the solution to my problem!
Thanks!! :)


> Utkarsh Ayachit <utkarsh.ayachit at kitware.com> hat am 8. September 2016 um
> 13:29 geschrieben:
> 
> 
> Something like following should do the trick:
> 
> def HasPreset(name):
>      presets = servermanager.vtkSMTransferFunctionPresets()
>      for i in range(presets.GetNumberOfPresets()):
>          if presets.GetPresetName(i) == name:
>              return True
>      return False
> 
> 
> 
> On Thu, Sep 8, 2016 at 3:52 AM,  <postgurke at web.de> wrote:
> > 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
> > _______________________________________________
> > 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
> >
> > Search the list archives at: http://markmail.org/search/?q=ParaView
> >
> > Follow this link to subscribe/unsubscribe:
> > http://public.kitware.com/mailman/listinfo/paraview


More information about the ParaView mailing list