[Paraview] Missing ColorArray after calling Slice() from python
Henning Glawe
glawe at mpi-halle.mpg.de
Tue Feb 26 10:56:57 EST 2013
Moin,
I have a problem on setting up multiple slices from a python script. When
setting up the second slice, the array I use for coloring is missing, and the
python interpreter raises an exception:
Traceback (most recent call last):
File "<string>", line 132, in <module>
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 212, in __setattr__
setter(self, value)
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 2385, in setProperty
return self.SetPropertyWithName(propName, value)
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 267, in SetPropertyWithName
prop.SetData(arg)
File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 745, in SetData
raise ValueError("Could not locate array %s in the input." % arr)
ValueError: Could not locate array CalcDensity in the input.
What exactly do I have to do in a python macro to have a field available for
colormapping ?
I try to setup a paraview pipeline of the following structure, but, as mentioned before, setting up the
second slice yields an exception.
input_vtk
|-Calculator
|-Slice1
|-Slice2
|-Slice3
|-...
Normals and Origins for the Slices are stored in a six-column textfile (tsv).
The python code in question is:
SetActiveSource(density_group)
DCalc = Calculator(density_group,registrationName="Density Calculator",
ResultArrayName = "CalcDensity", Function = calc_function)
DCalc.UpdatePipeline()
DCalc.UpdatePipelineInformation()
import os
f = open(filebase + '-cutplanes.tsv')
i = 0
for line in f:
sp = map(float,line.split())
SetActiveSource(DCalc)
i=i+1
s=Slice(DCalc,registrationName="Plane%d" % i)
s.SliceType.Normal=[ sp[0],sp[1],sp[2] ]
s.SliceType.Origin=[ sp[3],sp[4],sp[5] ]
s.UpdatePipeline()
s.UpdatePipelineInformation()
dp=GetDisplayProperties(s)
dp.ColorAttributeType = 'POINT_DATA'
dp.ColorArrayName = 'CalcDensity'
Show(s)
SetActiveSource(None)
Render()
--
Mit freundlichen Grüßen
Henning Glawe
Max-Planck-Institut für Mikrostrukturphysik
Weinberg 2, 06120 Halle (Saale), Germany http://www.mpi-halle.de/~theory
Phone: +49-345-5582-613 Fax: +49-345-5511223 Email: glawe at mpi-halle.de
More information about the ParaView
mailing list