On 05/12/2013 07:43 AM, Сергей Дмитриев wrote:
Hello.
I make the following data from the "Python Shell" in "Programmable Source"
In the "Python Shell" I write the following:
src=ProgrammableSource()
src.add_attribute('MyArray',[1,2,3])
Show()
In the ProgrammableSource Script I write the following:
array=self.MyArray
print array
######
Result:
Traceback (most recent call last):
File "<string>", line 24, in <module>
File "<string>", line 2, in RequestData
AttributeError: Array
How to pass an array between the two interpreters?
I would directly insert my array into the source filter. The following
example is a ParaView macro:
script = """
pdo = self.GetPolyDataOutput()
newPts = vtk.vtkPoints()
for x in [(1,1,1),(0,0,1),(0,1,0),(1,0,0)]:
newPts.InsertNextPoint(x)
lines = vtk.vtkCellArray()
for c in [[0,1,2,3,0],[0,2],[1,3]]:
lines.InsertNextCell(len(c))
for i in c:
lines.InsertCellPoint(i)
pdo.SetLines(lines)
pdo.SetPoints(newPts)
assert len(array) == pdo.GetNumberOfPoints()
varray = vtk.vtkDoubleArray();
varray.SetName(%r)
for x in %r:
varray.InsertNextValue(x)
pdo.GetPointData().AddArray(varray)
"""
name = "myarray"
array = [1,2,3,4]
src = ProgrammableSource(
OutputDataSetType='vtkPolyData',
Script=(script % (name, array)))
Show(src)
_______________________________________________
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
Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview