Hello,
I am working on the filter example in PluginsExamples
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.