# Need any example with FIlter using inside the Programmable Filter

**URL:** https://discourse.paraview.org/t/need-any-example-with-filter-using-inside-the-programmable-filter/1386
**Category:** ParaView Support
**Created:** [March 4, 2019, 12:57pm UTC](https://discourse.paraview.org/t/need-any-example-with-filter-using-inside-the-programmable-filter/1386 "2019-03-04T12:57:43Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Allrond](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/71e660/32.png) [@Allrond](https://discourse.paraview.org/u/Allrond)
#### Post date: [March 4, 2019, 12:57pm UTC](https://discourse.paraview.org/t/need-any-example-with-filter-using-inside-the-programmable-filter/1386/1 "2019-03-04T12:57:43Z")

</div>

I cant find no example with calling vtk filters inside th programmable filter.  
1)Created filter should not be in ParaView Pipeline Browser.  
2)It can be Glyph filter or Cutter filter or Threshold or ExtractSubset for StructuredGrid  
3)And, if it can be realised what vtk filter make ExtractSubset like ParaView?  
I see this something like:

input = self.GetInputDataObject(0, 0)  
InputCopy= input.NewInstance()  
InputCopy.ShallowCopy(input)

thFilter= vtk.vtkThreshold()  
thFilter.SetInputData(InputCopy)  
thFilter.Scalars = [‘CELLS’, ‘data’]  
thFilter.ThresholdRange = [1.0, 4.0]  
thFilter.Update()

self.GetOutputDataObject(0).ShallowCopy(thFilter.GetOutputDataObject(0))

---

<div class="post-metadata">

### Author: ![Allrond](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/71e660/32.png) [@Allrond](https://discourse.paraview.org/u/Allrond)
#### Post date: [March 5, 2019, 7:50am UTC](https://discourse.paraview.org/t/need-any-example-with-filter-using-inside-the-programmable-filter/1386/2 "2019-03-05T07:50:11Z")

</div>

Solved:  
import vtk  
inp = self.GetInputDataObject(0, 0)  
outp = self.GetOutputDataObject(0)  
thresh = vtk.vtkThreshold()  
thresh.SetInputData(inp)  
thresh.SetInputArrayToProcess(1, 0, 0,0, “dataScalar”)  
thresh.ThresholdBetween(1,5)  
thresh.Update()  
outp.ShallowCopy(thresh.GetOutput())

---

<div class="post-metadata">

### Author: ![DennisConklin](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/b19c9b/32.png) [@DennisConklin](https://discourse.paraview.org/u/DennisConklin)
#### Post date: [March 5, 2019, 12:39pm UTC](https://discourse.paraview.org/t/need-any-example-with-filter-using-inside-the-programmable-filter/1386/3 "2019-03-05T12:39:30Z")

</div>

Here’s another example of running Pass Arrays, followed by Point Data to Cell Data inside a Programmable Filter

```
   # run PassArrays and PointDataToCellData filters to get element variables faster
   # run on entire MultiBlockDataSet

   # use pass arrays to extract arrays of interest
   myArrays=vtk.vtkPassArrays()
   myArrays.SetInputDataObject(self.GetOutputDataObject(0))
   #myArrays.SetInputDataObject(self.GetInputDataObject(0,0))
   myArrays.ClearArrays()
   myArrays.AddPointDataArray('Z_undef')
   if (Radius_undeformed):
      myArrays.AddPointDataArray('Radius_undef')
   if (Sector_Angle_undeformed):
      myArrays.AddPointDataArray('Sector_Angle_undef')
   myArrays.AddCellDataArray('')
   myArrays.AddFieldDataArray('')

   # use point2cell to operate on the arrays we care about
   p2c = vtk.vtkPointDataToCellData()
   p2c.SetInputConnection(myArrays.GetOutputPort())
   p2c.Update()

```

Dennis

---

<div class="post-metadata">

### Author: ![MiguelAngelAGUIRRE](https://discourse.paraview.org/user_avatar/discourse.paraview.org/miguelangelaguirre/32/2986_2.png) [@MiguelAngelAGUIRRE](https://discourse.paraview.org/u/MiguelAngelAGUIRRE)
#### Post date: [October 28, 2020, 6:40pm UTC](https://discourse.paraview.org/t/need-any-example-with-filter-using-inside-the-programmable-filter/1386/4 "2020-10-28T18:40:22Z")

</div>

Hello,

This site has been very useful to figure out the implementation of vtk operations (which are used by the Paraview filters) into a Python programmable filter:

[https://lorensen.github.io/VTKExamples/site/Python/](https://lorensen.github.io/VTKExamples/site/Python/)

Regards

Miguel

---

<div class="post-metadata">

### Author: ![massisenergy](https://discourse.paraview.org/user_avatar/discourse.paraview.org/massisenergy/32/6229_2.png) [@massisenergy](https://discourse.paraview.org/u/massisenergy)
#### Post date: [August 18, 2021, 12:27pm UTC](https://discourse.paraview.org/t/need-any-example-with-filter-using-inside-the-programmable-filter/1386/5 "2021-08-18T12:27:20Z")

</div>

The person behind this work has passed away, but remains in his work (in many languages such as

- [C++](https://kitware.github.io/vtk-examples/site/Cxx/)
- [Python](https://kitware.github.io/vtk-examples/site/Python/)
- [Java](https://kitware.github.io/vtk-examples/site/Java/)
- [C#](https://kitware.github.io/vtk-examples/site/CSharp/)
- [js](https://kitware.github.io/vtk-examples/site/JavaScript/)

) here:

[https://kitware.github.io/vtk-examples/site/](https://kitware.github.io/vtk-examples/site/)
