[Paraview] Get value of a vtkintarray object by the filed name

Shayan Nikoohemat shayan.nikoohemat at gmail.com
Tue Aug 8 07:08:39 EDT 2017


I have a Paraview programmable filter written in python, that I am running
on a table of points to assign RGB colors as UnsignedCharArray. I'm just
stuck in one part of the code to get the value of R, G, B fields in the
range. Here is the table example:

[image: Inline image 1]

ids = self.GetInput()
ods = self.GetOutput()

ocolors = vtk.vtkUnsignedCharArray()
ocolors.SetName("colors")
ocolors.SetNumberOfComponents(3)
ocolors.SetNumberOfTuples(ids.GetNumberOfPoints())

inArray = ids.GetPointData().GetArray(0)for x in range(0,
ids.GetNumberOfPoints()):
  rF = inArray.GetValue(x) # here I need something like GetValue(x, "R")
  gF = inArray.GetValue(x) # here I need something like GetValue(x, "G")
  bF = inArray.GetValue(x) # here I need something like GetValue(x, "B")

  ocolors.SetTuple3(x, rF,gF,bF)

ods.GetPointData().AddArray(ocolors)

Can anyone help me to fix this.

The code source is from an old post from 2012.

Thanks.

Shayan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170808/75c6d2d2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 11808 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170808/75c6d2d2/attachment.png>


More information about the ParaView mailing list