Hi,
I’m trying to develop a plugin based on VTKPythonAlgorithmBase and I would like to let the user select the name of the PointData array to process.
I’ve found on internet that there is an ArrayListDomain XML property which gives the list of input array names. So I come with the following code:
from paraview.util.vtkAlgorithm import *
@smproxy.filter()
@smproperty.input(name="Input")
@smdomain.datatype(dataTypes=["vtkDataSet"], composite_data_supported=False)
class PreserveInputTypeFilter(VTKPythonAlgorithmBase):
"""
Example filter demonstrating how to write a filter that preserves the input
dataset type.
"""
def __init__(self):
super().__init__(nInputPorts=1, nOutputPorts=1, outputType="vtkDataSet")
self._array_name = ''
@smproperty.stringvector(name="Array", label="Array", number_of_elements="5", default="0", element_types="0 0 0 0 2", animateable="0")
@smdomain.xml("""
<ArrayListDomain name="array_list" attribute_type="Scalars" input_domain_name="inputs_array">
<RequiredProperties>
<Property name="Input" function="Input"/>
</RequiredProperties>
</ArrayListDomain>
""")
def SetArray(self, *args):
print("choosing array", args)
self._array_name = args
def RequestDataObject(self, request, inInfo, outInfo):
inData = self.GetInputData(inInfo, 0, 0)
outData = self.GetOutputData(outInfo, 0)
assert inData is not None
if outData is None or (not outData.IsA(inData.GetClassName())):
outData = inData.NewInstance()
outInfo.GetInformationObject(0).Set(outData.DATA_OBJECT(), outData)
return super().RequestDataObject(request, inInfo, outInfo)
def RequestData(self, request, inInfo, outInfo):
inData = self.GetInputData(inInfo, 0, 0)
outData = self.GetOutputData(outInfo, 0)
print("input type =", inData.GetClassName())
print("array :", self._array_name)
print("output type =", outData.GetClassName())
assert outData.IsA(inData.GetClassName())
return 1
I’ve seen in ArrayListDomain’s documentation that it should be possible to filter the kind of array:
- either with the “FieldDataSelection” function
- or with the “input_domain_name” attribute.
But I could’nt get this to work.
Does anyone have an idea on how to filter this list and display only array names associated with point data ?
Thanks in advance.