# filter with variable number of ouput ports - possible?

**URL:** https://discourse.paraview.org/t/filter-with-variable-number-of-ouput-ports-possible/4345
**Category:** Development
**Created:** [May 17, 2020, 3:21pm UTC](https://discourse.paraview.org/t/filter-with-variable-number-of-ouput-ports-possible/4345 "2020-05-17T15:21:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [May 17, 2020, 3:21pm UTC](https://discourse.paraview.org/t/filter-with-variable-number-of-ouput-ports-possible/4345/1 "2020-05-17T15:21:22Z")

</div>

Is it possible to write a ParaView filter in such a way that the number of output pipes is defined only during execution of the `RequestData(...)` function?

Or in more general terms: a filter where the number of output pipes depends on the input data.

The opposite is obviously different and easier: a filter where the number of input pipes is not fixed - like with the `vtkAppendDataSets` filter. The difference is obviously that the number of input pipes is still clear already before any further calculations are done, calling the `Update()` function which in turn results in calling the `RequestData(...)` function.

Possible use case: you have an input data set with an attribute that can act like a category, let’s call it “Level”, and then we want to split that input data set into as many data sets as we have levels. The specific use case that I have in mind is actually a “reader” type filter, i.e. which has an input file as input, but that may not be such a big difference.

So what would be requred is a function call that happens BEFORE the output data objects are generated, but where the input data are already known so the number of “Levels” could be counted.

Ideally there would be an existing filter that does the trick, but so far I did not find one!

In the past I had only cases that were slightly easier, like “minimum 4 and maximum 6 output pipes”: In these cases I specified the filter to have 6 output pipes which in some cases were simply not all filled (and for some I did not open a view by default, with some Hint in the SM XML file).

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [May 17, 2020, 3:26pm UTC](https://discourse.paraview.org/t/filter-with-variable-number-of-ouput-ports-possible/4345/2 "2020-05-17T15:26:37Z")

</div>

> [@cobo](#):
>
> a filter where the number of output pipes depends on the input data.

This is simply not supported. A better option is to put out a MultiblockDataSet with with “pipe” as a block under the root and then you can apply Extract Block to extract each pipe at runtime and build separate pipelines for each.

---

<div class="post-metadata">

### Author: ![cobo](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/c/f17d59/32.png) [@cobo](https://discourse.paraview.org/u/cobo)
#### Post date: [May 18, 2020, 1:26pm UTC](https://discourse.paraview.org/t/filter-with-variable-number-of-ouput-ports-possible/4345/3 "2020-05-18T13:26:20Z")

</div>

Thanks! So I can stop investigating and just try to find another better solution then!
