I’m brand new in the world of Programmable Filter. In my python script, I’m trying to merge the blocks of a Multi-block Dataset (and then some additionnal steps that are already working). With the GUI, I simply use the Merge Blocks filter.
I’ve tried the following:
input0 = inputs[0]
print(intput0) # -> paraview.vtk.numpy_interface.dataset_adapter.CompositeDataSet
if input0.IsA("vtkCompositeDataSet"):
from paraview.vtk.vtkFiltersGeneral import vtkMultiBlockMergeFilter
from vtk.numpy_interface import dataset_adapter as dsa
mbmf = vtkMultiBlockMergeFilter()
mbmf.SetInputData(input0.VTKObject)
mbmf.Update()
merged = dsa.WrapDataObject(mbmf.GetOutput())
print(merged) # -> vtk.numpy_interface.dataset_adapter.CompositeDataSet
but it seems that the merged object is still a CompositeDataSet (while I’m expecting something like an UnstructuredGrid). In the CXX doxygen I see a merge method but I don’t know how to use it (if needed).
However your line lead to ImportError: cannot import name 'vtkDataObjectTreeToPointSetFilter' from 'paraview.modules.vtkPVVTKExtensionsMisc' with ParaView-5.9.0-RC4-MPI-Linux-Python3.8-64bit.
But following your lead, I found a vtkMergeBlocks in paraview.modules.vtkPVVTKExtensionsMisc that did the job. I ended up with:
input0 = inputs[0]
if input0.IsA("vtkCompositeDataSet"):
from paraview.modules.vtkPVVTKExtensionsMisc import vtkMergeBlocks
from vtk.numpy_interface import dataset_adapter as dsa
mergeFilter = vtkMergeBlocks()
mergeFilter.SetInputData(input0.VTKObject)
mergeFilter.Update()
input0 = dsa.WrapDataObject(mergeFilter.GetOutput())
In the Python shell, GetActiveSource().GetVTKClassName() gives you the class name. You can then locate its VTK module by searching the ParaView source code.