[Paraview] Type error in programmable filter

Colin McAuliffe cjm2176 at columbia.edu
Thu May 16 21:24:13 EDT 2013


Hello all,

I am writing a pvpython script which takes a pvd, applies an integrate  
variables filter, then uses a programmable filter to scale out the  
length, area, or volume (depending on whether the data is 1,2, or 3d)  
from each of the point data, then finally applies a plot selection  
over time filter to the result. It works fine most of the time, but  
occasionally the programmable filter gives the following error:

Traceback (most recent call last):
   File "<string>", line 26, in <module>
   File "<string>", line 23, in RequestData
   File  
"/Applications/ParaView.app/Contents/Python/paraview/vtk/dataset_adapter.py",  
line 196, in append
     arr = numpyTovtkDataArray(narray, name)
   File  
"/Applications/ParaView.app/Contents/Python/paraview/vtk/dataset_adapter.py",  
line 53, in numpyTovtkDataArray
     vtkarray = numpy_support.numpy_to_vtk(array)
   File  
"/Applications/ParaView.app/Contents/Python/paraview/numpy_support.py", line  
160, in numpy_to_vtk
     result_array.SetVoidArray(z_flat, len(z_flat), 1)
TypeError: argument 1: value is _c_A
W5 at k5?, required type is void_p

The error is occurring in the last line of the script which is below.  
I'm not sure where to start looking for problems since the data I am  
using seems fine. Any suggestions? Thanks!

All the best
Colin


         script = "inp = inputs[0]\n" + \
                  "#Determine length, area, or volume\n" + \
                  "lav = ['Length','Area','Volume']\n" + \
                  "if not inp.GetCellData() is None:\n" + \
                  "    if inp.GetCellData().GetNumberOfArrays() > 0:\n" + \
                  "        for CellArrayIdx in  
range(0,inp.GetCellData().GetNumberOfArrays()):\n" + \
                  "            data =  
inp.GetCellData().GetArray(CellArrayIdx)\n" + \
                  "            name =  
inp.GetCellData().GetArrayName(CellArrayIdx)\n" + \
                  "            if name in lav:\n" + \
                  "                LAV = data.GetTuple(0)[0]\n" + \
                  "#Scale point data by LAV\n" + \
                  "npa = inp.GetPointData().GetNumberOfArrays()\n" + \
                  "nams= [0]*npa\n" + \
                  "if not inp.GetPointData() is None:\n" + \
                  "    if inp.GetPointData().GetNumberOfArrays() > 0:\n" + \
                  "        for PointArrayIdx in  
range(0,inp.GetPointData().GetNumberOfArrays()):\n" + \
                  "            name =  
inp.GetPointData().GetArrayName(PointArrayIdx)\n" + \
                  "            nams[PointArrayIdx] = name\n" + \
                  "for n in nams:\n" + \
                  "    data = inp.PointData[n]\n" + \
                  "    print n,LAV,data\n" + \
                  "    output.PointData.append(data/LAV,n)"


-- 
Colin McAuliffe
PhD Candidate
Columbia University
Department of Civil Engineering and Engineering Mechanics


More information about the ParaView mailing list