Use output of filter for input of other filters

I have been looking around the forum in similar questions but I can not finish of getting it.
lets say I want to get all the data of a filter that is shown if I show it in a spreadsheet, as a list of arrays, inside my python script that I will then use in pvbatch so I completely automatize my workflow and at the same time I make it it a little bit more ‘inteligent’.
the behavior I am looking for would be the exactly result of doing something like:

spreadSheetView1 = CreateView('SpreadSheetView')
createdFilterObject#whateverFilter, BoundingRuler, ExtractBlock, Slice, etc
Show(createdFilterObject, spreadSheetView1, 'SpreadSheetRepresentation')
ExportView(casePath+'/createdFilterObject.csv', view=spreadSheetView1)

then import the csv.
I have saw that in some post it was suggest Fetch() in others servermanager.Fetch(createdFilterObject) I also came across with ‘vtk_to_numpy’ and lastly use directly like createdFilterObject.PointData["Points"] but for some filters works, for other no.
how can I do this in a clean way?
like having as input any filter and as output what is shown in the spread sheet?
thanks in advance

servermanager.fetch is indeed the way to go

Hello mathieu,
but from servermanager.fetch I get a vtk object that from this sometimes there are some properties sometimes not… for example here it is used this after the servermanager.fetch
calc_vtk.GetPointData() link where calc_vtk is the result of servermanager.fetch(filter) but for example if I do the following I get an empty result:

import paraview.servermanager as sm
boundingRuler1 = BoundingRuler(registrationName='boundingRuler1', Input=s, Axis = 'X Axis')
ruler = sm.Fetch(boundingRuler1)

what I am missing? the boundingRuler has point data and also has the array Points

Because a ruler is a very special kind of filter that is client side only. Use GetClientSideObject() instead.

is there a list of one or another? furthermore I should use it when? because ruler.GetClientSideObject() gives an error

nevermind, servermanager.fetch works for bounding ruler:

>>> a=BoundingRuler()
>>> Show(a)
<paraview.servermanager.RulerSourceRepresentation object at 0x7f8bf499b8d0>
>>> Render()
<paraview.servermanager.RenderView object at 0x7f8bf4cdad10>
>>> obj=servermanager.Fetch(a)
>>> obj.GetNumberOfPoints()

yes, but how I get the entire array of it? that has [[x,y,z],[x0,y0,z0]]

I should treat each filter differently? If I want to transform the points in a slice. or another thing? that’s what I don’t understand, to completely transform a column to an array. as it was logic for me to this line: ruler.GetPointData().GetArray('Points')

You are getting a VTK object, not a numpy wrapped array. You can either 1. wrap it using the dataset adapter and 2. access it using VTK directly.

In that case 2. is trivial.


If I want to transform the points in a slice. or another thing?

Then you should use the dataset adapter and get a numpy wrapped object

but this would not be the general solution to each type? what I want to get is the data sets of whatever the filter is, get what spreadsheet of that filter shows me… in that case how should I do it?

It should work for all filters.

sorry but which one? could you elaborate?

thanks for the help by the way

Both 1. and 2. are general methods.

what I want to get is the data sets of whatever the filter is,


get what spreadsheet of that filter shows me

The spreadsheet is accumulating the data in different way depending on the datatype. Moreover, the spreadsheet can show pointdata or celldata.

Points and PointData arrays cannot be recovered the same way all the time. If you are working with the same kind of data, then you should be able to generalize.

Hello mathieu,
sorry to continue bothering you with this, but once we have the VTK object, how we wrap it the data set to make the numpy array?
thanks in advance,

In short:

from vtk.numpy_interface import dataset_adapter as dsa
numpyPD = dsa.WrapDataObject(servermanager.Fetch(ruler))

more info:

1 Like

Thanks a lot mathieu,

this helped me a lot, and furthermore, the info you gave me threw a little bit of light to the subject. one last thing I bother you with, do you have by any means info about the types of data? because I find it as the last peace of the puzzle as for example when we look at point data we also see points inside of it (in speed sheet view) while in reality we access this data in separate places. what in part 2 is mentioned as:

It is possible to access PointData, CellData, FieldData, Points (subclasses of vtkPointSet only), Polygons (vtkPolyData only) this way.

what is in the info is in each data type? what are all the data types? is there any ‘list’ with this info? thanks in advance

what is in the info is in each data type?

Please clarify your question

what are all the data types?

what is in the info is in each data type?

Please clarify your question

I mean there is pointData, cellData, Points, and looks like at least FieldData and polygons, if there any other and to know what are in each of this types? as for example when we show the pointData of a filter we also see in the table the Points, that is what perturbates me. to know if I am looking for a field that I can see where to go to see if I can recover it…

1 Like