# Inspect certain field data of a pipeline object in a Paraview python script

**URL:** https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278
**Category:** ParaView Support
**Tags:** python
**Created:** [May 7, 2020, 11:52am UTC](https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278 "2020-05-07T11:52:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ju-kreber](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ju-kreber/32/4083_2.png) [@ju-kreber](https://discourse.paraview.org/u/ju-kreber)
#### Post date: [May 7, 2020, 11:52am UTC](https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278/1 "2020-05-07T11:52:21Z")

</div>

Hello,

I’m writing a Python script (macro) in Paraview and I’m currently facing the following problem: My data source is a VTK XML file that is opened in Paraview, which, apart from the geometry and point data, should also contain some additional custom data. I intend to store it simply as unaligned field data there. Now depending on this custom data, from my Python script, I have to apply a varying number of filters to the data. So the main question is how to best access this field data from the client-side Paraview script.

I know that I can use `servermanager.Fetch()` to get the whole object sent to the client, which would be somewhat okay since so far, I’m not using a remote server. However since I’m only interested in a tiny piece of data (that one field), I wanted to ask if there’s a better method to access it, since I really want to refrain from transmitting the whole structure if at some point I’m actually using a remote connection.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 11, 2020, 5:42am UTC](https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278/2 "2020-05-11T05:42:48Z")

</div>

Why are you accessing the data ? If you want to process the data, you should use a Programmable Filter.

---

<div class="post-metadata">

### Author: ![ju-kreber](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ju-kreber/32/4083_2.png) [@ju-kreber](https://discourse.paraview.org/u/ju-kreber)
#### Post date: [May 11, 2020, 11:13am UTC](https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278/3 "2020-05-11T11:13:55Z")

</div>

Hi, thanks for the response.

The problem is that I want to extract a varying number of objects out of the data. As far as I know, there is no possibility of having a filter with a variable number of outputs, or am I mistaken? This is why I thought to apply the same filter a number of times, parameterized by the object to extract. But this I would have to do client-side, right?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 12, 2020, 1:52am UTC](https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278/4 "2020-05-12T01:52:59Z")

</div>

> As far as I know, there is no possibility of having a filter with a variable number of outputs

Indeed, for that usecase we tend to use multiblocks output.

In any case, your idea could work using fetch(). You can use param to recover only a integrated version of the data, but I’m not sure that the field data would still be available. Another solution could be to write a programmable filter to do the integration before you do the fetch.

---

<div class="post-metadata">

### Author: ![ju-kreber](https://discourse.paraview.org/user_avatar/discourse.paraview.org/ju-kreber/32/4083_2.png) [@ju-kreber](https://discourse.paraview.org/u/ju-kreber)
#### Post date: [May 13, 2020, 6:20pm UTC](https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278/5 "2020-05-13T18:20:05Z")

</div>

> [@mwestphal](#):
>
> Indeed, for that usecase we tend to use multiblocks output.

Oh, I was not aware that something like this exists. Actually, multiple blocks as output would be perfectly fine. So can I write a programmable filter that takes a single-block dataset as input and creates a multi-block output? Can you provide me with some reference for this? In the docs I only found how to process already-existing multiblock data.

> [@mwestphal](#):
>
> You can use param to recover only a integrated version of the data

Sorry, but what do you mean by that? Unfortunately I’m not that familiar with VTK, so what would an integrated version of the data be?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [May 14, 2020, 4:11am UTC](https://discourse.paraview.org/t/inspect-certain-field-data-of-a-pipeline-object-in-a-paraview-python-script/4278/6 "2020-05-14T04:11:34Z")

</div>

> [@ju-kreber](#):
>
> So can I write a programmable filter that takes a single-block dataset as input and creates a multi-block output?

Yes.

> Can you provide me with some reference for this? In the docs I only found how to process already-existing multiblock data.

You can use VTKPython example for this : [https://lorensen.github.io/VTKExamples/site/Python/CompositeData/MultiBlockDataSet/](https://lorensen.github.io/VTKExamples/site/Python/CompositeData/MultiBlockDataSet/)

Especially this part :

```
# PART 1 Make some Data.
# Make a tree.
root = vtk.vtkMultiBlockDataSet()

branch = vtk.vtkMultiBlockDataSet()
root.SetBlock(0, branch)

# Make some leaves.
leaf1 = vtk.vtkSphereSource()
leaf1.SetCenter(0, 0, 0)
leaf1.Update()
branch.SetBlock(0, leaf1.GetOutput())

leaf2 = vtk.vtkSphereSource()
leaf2.SetCenter(1.75, 2.5, 0)
leaf2.SetRadius(1.5)
leaf2.Update()
branch.SetBlock(1, leaf2.GetOutput())

leaf3 = vtk.vtkSphereSource()
leaf3.SetCenter(4, 0, 0)
leaf3.SetRadius(2)
leaf3.Update()
root.SetBlock(1, leaf3.GetOutput())

```
