[Paraview] using with python to use filter NO work only on 3.5 (I think a bug)
BOUSSOIR Jonathan 167706
Jonathan.BOUSSOIR at cea.fr
Tue May 19 06:13:21 EDT 2009
Hi all,
I am using Linux and Paraview 3.4 or 3.5. I have one question when I use a filter on Paraview 3.5 I have a error.
I laught python script with pvpython (or ipython) and paraview 3.4 my script is running but with paraview 3.5 I have been a Attribut Error with :reprShrink.ColorArrayName = "Normals"
I don't know why it don't understand a attribut "Normals" on paraview 3.5
There my script belong, if someone can help me to understand where is my bug.
I am new to paraview, but I think it's a bug in Paraview 3.5. What do you think?
Thanks in advance for your kind help.
Regards,
Jona
---------------------------------------------------------------------------
The error messages (only Paraview 3.5) :
>>> reprShrink.ColorArrayName = "Normals"
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (960, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (911, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (500, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (644, 0))
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/myrrha/<ipython console> in <module>()
/home/myrrha/Desktop/paraview/paraview3.5/paraview-bin/Utilities/VTKPythonWrapping/paraview/servermanager.pyc in __setattr__(self, name, value)
201 self.__dict__[name] = value
202 else:
--> 203 setter(self, value)
204
205 def add_attribute(self, name, value):
/home/myrrha/Desktop/paraview/paraview3.5/paraview-bin/Utilities/VTKPythonWrapping/paraview/servermanager.pyc in setProperty(self, value)
2306 propName = pName
2307 def setProperty(self, value):
-> 2308 return self.SetPropertyWithName(propName, value)
2309 return setProperty
2310
/home/myrrha/Desktop/paraview/paraview3.5/paraview-bin/Utilities/VTKPythonWrapping/paraview/servermanager.pyc in SetPropertyWithName(self, pname, arg)
250 if prop is None:
251 raise RuntimeError, "Property %s does not exist. Please check the property name for typos." % pname
--> 252 prop.SetData(arg)
253
254 def GetPropertyValue(self, name):
/home/myrrha/Desktop/paraview/paraview3.5/paraview-bin/Utilities/VTKPythonWrapping/paraview/servermanager.pyc in SetData(self, value)
661
662 found = False
--> 663 for a in self.Available:
664 if a[1] == arr and (not att or att == a[0]):
665 att = a[0]
/home/myrrha/Desktop/paraview/paraview3.5/paraview-bin/Utilities/VTKPythonWrapping/paraview/servermanager.pyc in __getattr__(self, name)
517 def __getattr__(self, name):
518 "Unknown attribute requests get forwarded to SMProperty."
--> 519 return getattr(self.SMProperty, name)
520
521 class GenericIterator(object):
AttributeError: Available
---------------------------------------------------------------------------
My script is :
#!/usr/bin/python
# -*- coding: latin-1 -*-
from paraview import servermanager
connection = servermanager.Connect('localhost')
sphere = servermanager.sources.SphereSource(PhiResolution=20, ThetaResolution=20, Radius=0.5, Center=[0, 0, 0])
view = servermanager.CreateRenderView()
reprShrink = servermanager.CreateRepresentation(sphere, view)
# Now set up the scalar coloring. We want to color by the 1st component of the
# "Normals" array.
# Choose the attribute type. Acceptable values are "POINT_DATA" (or 0),
# "CELL_DATA" (or 1)
reprShrink.ColorAttributeType = "POINT_DATA"
# Select the name of the array to color with.
reprShrink.ColorArrayName = "Normals"
# Now create a lookup-table to map the scalar values to colors.
lut = servermanager.rendering.PVLookupTable()
lut.RGBPoints = [0.0, 0.0, 0.0, 1.0,
1.0, 1.0, 0.0, 0.0]
# Since we want to color by the 1st component of the normals vector
lut.VectorComponent = 1
lut.VectorMode = "Component" ;# Another acceptable value is "Magnitude" to
# color by vector magnitude.
# Assign the lut to the representation
reprShrink.LookupTable = lut
view.ResetCamera()
view.StillRender()
More information about the ParaView
mailing list