[Paraview] Python Scripting
Shawn Waldon
shawn.waldon at kitware.com
Mon May 29 09:27:14 EDT 2017
Hi Richard,
Since you didn't specify the version you are using I'm using 5.4-RC3 for
this answer. I loaded a dataset and ran the Python Trace (Tools -> Start
Trace) to find out what it is doing. Here is the python script that was
generated from changing what the dataset was colored by.
# get active source.
canex2 = GetActiveSource()
# get active view
renderView1 = GetActiveViewOrCreate('RenderView')
# uncomment following to set a specific view size
# renderView1.ViewSize = [1330, 670]
# get display properties
canex2Display = GetDisplayProperties(canex2, view=renderView1)
# set scalar coloring
ColorBy(canex2Display, ('POINTS', 'VEL', 'Magnitude'))
# get color transfer function/color map for 'vtkBlockColors'
vtkBlockColorsLUT = GetColorTransferFunction('vtkBlockColors')
# Hide the scalar bar for this color map if no visible data is colored by it.
HideScalarBarIfNotNeeded(vtkBlockColorsLUT, renderView1)
# rescale color and/or opacity maps used to include current data range
canex2Display.RescaleTransferFunctionToDataRange(True, False)
# show color bar/color legend
canex2Display.SetScalarBarVisibility(renderView1, True)
# get color transfer function/color map for 'VEL'
vELLUT = GetColorTransferFunction('VEL')
It is hiding the scalar bar for vtkBlockColors since that is what the data
used to be colored by. I think your problem will be solved by using the
GetDisplayProperties and ColorBy functions rather than setting
ColorArrayName.
HTH,
Shawn
On Sat, May 27, 2017 at 1:35 PM, Richard Kalhoefer <
kalhoefer at physik.uni-kiel.de> wrote:
> Hey,
>
> I have a python script that opens a Legacy VTK file that contains two
> scalar arrays of the same length (real and imaginary part of a wave
> function) and then adjusts the camera settings, representation and color.
> My transfer functions seem to be ignored and I just get full opacity and
> black color. Running the script inside the GUI's python shell gives the
> same result, but when I then change the array under Display->Coloring to
> the other one and back again. everything looks as expected. So my question
> is: What is this GUI element doing beyond "GetRepresentation(reader,
> view).ColorArrayName = ['POINTS', arrayname]" and how can I do the same
> within the python script?
>
> Kind regards
> Richard Kalhöfer
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170529/2ccb387e/attachment.html>
More information about the ParaView
mailing list