Tutorial python script don't work on paraview 3.5
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Hi, When I laught python script with pvpython (or ipython) and paraview 3.4 my script (see below in more information) 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 Is it a bug?
Bests, Jona
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/ in ()
/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()