# Creating custom filter in Python

**URL:** https://discourse.vtk.org/t/creating-custom-filter-in-python/15854
**Category:** Support
**Tags:** python
**Created:** [July 23, 2025, 11:10pm UTC](https://discourse.vtk.org/t/creating-custom-filter-in-python/15854 "2025-07-23T23:10:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![citronella3alain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/citronella3alain/32/10080_2.png) [@citronella3alain](https://discourse.vtk.org/u/citronella3alain)
#### Post date: [July 23, 2025, 11:10pm UTC](https://discourse.vtk.org/t/creating-custom-filter-in-python/15854/1 "2025-07-23T23:10:59Z")

</div>

I’ve not found many examples of creating custom vtk filters in python so I followed this one: [Developing Custom Filters and Algorithms in VTK](https://adamdjellouli.com/articles/vtk_examples/09_custom_filters_and_algorithms)

However, it doesn’t seem to work:  
[custom\_filter.ipynb](https://discourse.vtk.org/uploads/short-url/vlHD7RajMEFLL4gpsTLUhmh12LL.ipynb) (7.8 KB)

It doesn’t seem that the `RequestData` method is being called (at least my dummy print statements don’t seem to be run) and the output is basically empty.

Could someone point me to updated python examples of custom filters / inform me what changes have happened since this example was published?

Thanks!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [July 24, 2025, 11:55am UTC](https://discourse.vtk.org/t/creating-custom-filter-in-python/15854/2 "2025-07-24T11:55:35Z")

</div>

This tutorial is not official as you may have realized.

Find hundreds of examples here:

[https://examples.vtk.org/site/](https://examples.vtk.org/site/)

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)
#### Post date: [July 24, 2025, 1:00pm UTC](https://discourse.vtk.org/t/creating-custom-filter-in-python/15854/3 "2025-07-24T13:00:22Z")

</div>

Creating custom filters with Python alone via subclassing won’t work. The C++ virtual dispatch mechanism won’t consider your Python overridden methods. One way to create a customer filter in Python is to create it in C++ and then let VTK’s language wrapping tools provide Python bindings for you. But that’s a fair amount of work.

A better route is to use [vtkPythonAlgorithm](https://vtk.org/doc/nightly/html/classvtkPythonAlgorithm.html). You can find out more about them in blog posts [vtkPythonAlgorithm is great](https://www.kitware.com/vtkpythonalgorithm-is-great/) and [Developing HDF5 readers using vtkPythonAlgorithm](https://www.kitware.com/developing-hdf5-readers-using-vtkpythonalgorithm/). There are numerous examples in the VTK code base in the form of tests:

- [Filters/Python/Testing/Python/TestPythonAlgorithm.py](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/Python/Testing/Python/TestPythonAlgorithm.py)
- [Common/DataModel/Testing/Python/TestPartitionedData.py](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Common/DataModel/Testing/Python/TestPartitionedData.py)
- [Filters/General/Testing/Python/TestGroupTimeStepsFilter.py](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/General/Testing/Python/TestGroupTimeStepsFilter.py)
- etc. (find more by searching for `vtkPythonAlgorithm` in the VTK source.

I hope that helps.
