# How to incorporate input field values in ProgrammableFilter plugin

**URL:** https://discourse.paraview.org/t/how-to-incorporate-input-field-values-in-programmablefilter-plugin/5489
**Category:** Development
**Tags:** python
**Created:** [October 4, 2020, 9:01pm UTC](https://discourse.paraview.org/t/how-to-incorporate-input-field-values-in-programmablefilter-plugin/5489 "2020-10-04T21:01:22Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mohamed\_Abdelkhalek](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mohamed_abdelkhalek/32/4384_2.png) [@Mohamed\_Abdelkhalek](https://discourse.paraview.org/u/Mohamed_Abdelkhalek)
#### Post date: [October 4, 2020, 9:01pm UTC](https://discourse.paraview.org/t/how-to-incorporate-input-field-values-in-programmablefilter-plugin/5489/1 "2020-10-04T21:01:22Z")

</div>

Hello,

I am working on the filter example in [PluginsExamples](https://github.com/Kitware/ParaView/blob/master/Examples/Plugins/PythonAlgorithm/PythonAlgorithmExamples.py)

> from paraview.util.vtkAlgorithm import \*
> 
> # ------------------------------------------------------------------------------
> 
> # A filter example.
> 
> # ------------------------------------------------------------------------------
> 
> @smproxy.filter()  
> @smproperty.input(name=“InputImage”, port\_index=0)  
> @smproperty.stringvector(name=“PythonPath”, value=“C:\Users\mkih2\Work\my-tools”)  
> @smdomain.datatype(dataTypes=[“vtkImageData”], composite\_data\_supported=False)  
> class PythonCropImage(VTKPythonAlgorithmBase):  
> def **init** (self):  
> VTKPythonAlgorithmBase. **init** (self, nInputPorts=1, nOutputPorts=1, outputType=“vtkImageData”)
> 
> ```
> def FillInputPortInformation(self, port, info):
> info.Set(self.INPUT_REQUIRED_DATA_TYPE(), "vtkImageData")
> 
> return 1
> 
> def RequestData(self, request, inInfoVec, outInfoVec):
> from vtkmodules.vtkCommonDataModel import vtkImageData
> from vtkmodules.numpy_interface import dataset_adapter as dsa
> 
> input0 = dsa.WrapDataObject(vtkImageData.GetData(inInfoVec[0], 0))
> output = dsa.WrapDataObject(vtkImageData.GetData(outInfoVec, 0))
> 
> from foo import bar
> 
> param = 25
> bar(param)
> 
> return 1
> 
> # TODO NOT WORKING (HOW TO GET THE VALUE IN REQUEST DATA ?)
> @smproperty.intvector(name="ParamInt", default_values=25)
> @smdomain.intrange(min=10, max=50)
> def SetParamInt(self, x):
> self._realAlgorithm.SetParamInt(x)
> self.Modified()
> 
> ```

I was successful add the smpdecorator for setting a custom python path (`@smproperty.stringvector(name="PythonPath", value="C:\\Users\\mkih2\\Work\\my-tools"`), for allowing the importing of functionality from external python code. However, in the example which is for a 2 input filter or the superquadric source example. It is not clear how get the value of **param** in the **RequestData** function ?

Thank you.

---

<div class="post-metadata">

### Author: ![Mohamed\_Abdelkhalek](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mohamed_abdelkhalek/32/4384_2.png) [@Mohamed\_Abdelkhalek](https://discourse.paraview.org/u/Mohamed_Abdelkhalek)
#### Post date: [October 6, 2020, 3:38am UTC](https://discourse.paraview.org/t/how-to-incorporate-input-field-values-in-programmablefilter-plugin/5489/2 "2020-10-06T03:38:09Z")

</div>

I was able to fix it by setting a variable name directly to the self object.

> @smproperty.intvector(name=“ParamInt”, default\_values=25)  
> @smdomain.intrange(min=10, max=50)  
> def SetParamInt(self, x):  
> self.\_param = x  
> self.Modified()

And access it in request data like so.

> from foo import bar  
> param = self.\_param  
> bar(param)
