I’m trying to threshold datasets in a vtkMultiBlockDataSet, but the filter returns a None type - I’m working in Python 3.8.2 and vtk 9.0.1
The code fragment is shown below and export is returned as None
The input is a vtkMultiBlockDataSet containing vtkUnstrucutredGrids. I’ve exported it and confirmed using Paraview that it’s in good shape - and I can do the threshold in Paraview.
Why? vtkThreshold sub-classes vtkUnstructuredGridAlgorithm. If you look at it’s ::GetOutput() method, it returns an unstructured grid instead of a multi-block dataset. It tries to down-cast the multi-block dataset output to an unstructured grid. Doing that in C++ gives a nullptr, hence you get None
::GetOutputDataObject() returns the real data object. Lucky for you the wrappers take care of the down-cast magic and you get a multiblock dataset
Thanks @jaswantp!!! That makes sense.
In fact, I worked around the issue by just iterating over the blocks in the mbds and calling threhold on the individual; ugrids.
Then last night I discovered vtkPythonAlgorithm… and as I worked my way through that I noticed that Algorithms don’t actually support GetOutput()… which helped me understand some issues about using GetOutput(), GetOutputDataObject() that I hadn’t really taken on board before…
In fact, I worked around the issue by just iterating over the blocks in the mbds and calling threhold on the individual; ugrids.
You are duplicating whatever the vtk library already does automatically. vtkCompositeDataPipeline (the default pipeline for almost every vtk filter) already does this for you when input is a multi-block dataset and puts those blocks into an output multiblock dataset… You could iterate over this output rather than calling an update in a python loop for each block!