# Is there any way to use vtkPythonAlgorithmBase Filters WITHOUT pv.LoadPlugin?

**URL:** https://discourse.paraview.org/t/is-there-any-way-to-use-vtkpythonalgorithmbase-filters-without-pv-loadplugin/12248
**Category:** ParaView Support
**Tags:** vtk, python
**Created:** [June 7, 2023, 10:28am UTC](https://discourse.paraview.org/t/is-there-any-way-to-use-vtkpythonalgorithmbase-filters-without-pv-loadplugin/12248 "2023-06-07T10:28:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![konn](https://discourse.paraview.org/user_avatar/discourse.paraview.org/konn/32/11784_2.png) [@konn](https://discourse.paraview.org/u/konn)
#### Post date: [June 7, 2023, 10:28am UTC](https://discourse.paraview.org/t/is-there-any-way-to-use-vtkpythonalgorithmbase-filters-without-pv-loadplugin/12248/1 "2023-06-07T10:28:23Z")

</div>

Hi,

First of all, thank you to all the ParaView developers for making this fantastic product! Our team has been using ParaView for serious visualisation tasks in production.

In our use case, we are writing ParaView Python Script to automate the everyday visualisation and analysis works.  
In some complex tasks, we need to implement custom filters - for example, calculating momentum on the specified surfaces, annotating the images with the upper/lower bound of the specified data, etc.

Originally, we used ProgrammableFilters to implement such filters. But it becomes quickly tedious to maintain Python scripts that contain ProgrammableFilters, as they accept Python code as a _string_. The problems are that we cannot apply IDE features directly to those input and we cannot reuse them from other programs.

Fortunately, we found a very nice mechanism for it - [`vtkPythonAlgorithmBase`](https://kitware.github.io/paraview-docs/latest/python/paraview.util.vtkAlgorithm.html) approach. This works quite nicely, as we can implement custom filters as a _real_ Python script, and we can load it as a custom plugin from ParaView the GUI App.

But here is the question: is there any ways to load `vtkPythonAlgorighmBase`-based filters WITHOUT resorting to `paraview.simple.LoadPlugin`?  
More specifically, I have the following questions:

1. Is there any way to use plugins defined in the _same_ file as the ParaView Python Script being executed? In other words, is there any way to use locally-defined vtkPythonAlgorithmBase filters?

2. Is it possible to use Python `import` statement to load external vtkPythonAlgorithmBase filters? Currently, we need to use a dirty hack something like:

Thank you 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: [June 7, 2023, 12:09pm UTC](https://discourse.paraview.org/t/is-there-any-way-to-use-vtkpythonalgorithmbase-filters-without-pv-loadplugin/12248/2 "2023-06-07T12:09:46Z")

</div>

Hi @konn

Welcome and Thanks for the kind words!

> Is there any way to use plugins defined in the _same_ file as the ParaView Python Script being executed?  
> Is it possible to use Python `import` statement to load external vtkPythonAlgorithmBase filters?

I’m afraid there is nothing more than the hack you are using, that being said I think this is a usecase that woul make sense to support more cleanly\>

Another way to look at it is to use generic plugin automatic loading capabilities. You could rely on PV\_PLUGIN\_PATH and other similar mechanism to load the plugin. See here for the doc:  
[https://www.paraview.org/Wiki/ParaView/Plugin\_HowTo#Using\_Plugins](https://www.paraview.org/Wiki/ParaView/Plugin_HowTo#Using_Plugins)

You would be able to load your plugin with:

`PV_PLUGIN_PATH=/path/to/dir paraview`

Sadly the doc is outdated a bit, needs to be ported to the new docs.

---

<div class="post-metadata">

### Author: ![konn](https://discourse.paraview.org/user_avatar/discourse.paraview.org/konn/32/11784_2.png) [@konn](https://discourse.paraview.org/u/konn)
#### Post date: [June 8, 2023, 2:49am UTC](https://discourse.paraview.org/t/is-there-any-way-to-use-vtkpythonalgorithmbase-filters-without-pv-loadplugin/12248/3 "2023-06-08T02:49:31Z")

</div>

Hi @mwestphal,

Thank you for your quick reply!

> I’m afraid there is nothing more than the hack you are using, that being said I think this is a usecase that woul make sense to support more cleanly

Thank you for your information. Yes, it would be great to have such a mechanism!

> Another way to look at it is to use generic plugin automatic loading capabilities. You could rely on PV\_PLUGIN\_PATH and other similar mechanism to load the plugin. See here for the doc:  
> [https://www.paraview.org/Wiki/ParaView/Plugin\_HowTo#Using\_Plugins](https://www.paraview.org/Wiki/ParaView/Plugin_HowTo#Using_Plugins)
> 
> You would be able to load your plugin with:
> 
> PV\_PLUGIN\_PATH=/path/to/dir paraview

Thank you for pointing it out! It seems a good tentative workaround for the time being. Concerning the security, it might be still good to have a mechanism to load locally-defined filters and/or specified filters by import, as it gives finer-grained control. Is there any possibility that such a feature gets implemented anytime soon?

---

<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: [June 8, 2023, 6:18am UTC](https://discourse.paraview.org/t/is-there-any-way-to-use-vtkpythonalgorithmbase-filters-without-pv-loadplugin/12248/4 "2023-06-08T06:18:23Z")

</div>

> [@konn](#):
>
> specified filters by import,

`PV_PLUGIN_CONFIG_FILE` let you point a json file allowing for a finer grain.

That being said, I do thing improving the `LoadPlugin` method to be able to find plugin easily, eg in the local dir, would be a great addition, but that would require funding or contribution.

> [@How are features and bug fixes incorporated into ParaView?](https://discourse.paraview.org/t/how-are-features-and-bug-fixes-incorporated-into-paraview/4735):
>
> As with all open source projects, adding features and fixing bugs takes developer effort. That effort may originate from volunteer community contributors, or through paid professional services offered by companies like [Kitware](https://www.kitware.com). Features and bug fixes are prioritized by the needs of contributing community members and by professional services customers. Note that contributions are vetted by a rigorous community review and testing process; therefore it is recommended that significant changes are d…

---

<div class="post-metadata">

### Author: ![konn](https://discourse.paraview.org/user_avatar/discourse.paraview.org/konn/32/11784_2.png) [@konn](https://discourse.paraview.org/u/konn)
#### Post date: [June 8, 2023, 8:54am UTC](https://discourse.paraview.org/t/is-there-any-way-to-use-vtkpythonalgorithmbase-filters-without-pv-loadplugin/12248/5 "2023-06-08T08:54:55Z")

</div>

> [@mwestphal](#):
>
> `PV_PLUGIN_CONFIG_FILE` let you point a json file allowing for a finer grain.

Aha, that makes more sense!

> [@mwestphal](#):
>
> That being said, I do thing improving the `LoadPlugin` method to be able to find plugin easily, eg in the local dir, would be a great addition, but that would require funding or contribution.

Got it. I think the workarounds you pointed out works fine for the time being, but when we really need more improvements, we will consider that direction 👍 Thank you for your kind replies and suggestions!
