2

I'm trying to write a python programmable source in Paraview that will create a vtkMultiBlockDataSet. I see that my python script in the programmable source gets a symbol called output which is of type vtk.numpy_interface.dataset_adapter.CompositeDataSet. How do I use that object to set the blocks? The only methods I see are to set things like points and cells.

My code creates a vtk.vtkMultiBlockDataSet. Can I somehow just set output to be this thing that I make? Or do I need to copy? Thanks for any advice! -- Adam

Adam
  • 153
  • 9

1 Answers1

2

In the Programmable Source, remember to check that the "output data set type" is set to vtkMultiblockDataSet

At this point, you can just write

self.GetOutput().ShallowCopy(vtkMultiBlockDataSetCreatedByYourCode)

output,inputs[0] ... are dataset_adapter which allow you to easily access vtkarrays as numpy arrays (e.g, if inputs[0] is a vtkpolydata, you can just do v2 = 2 * inputs.PointData['v'] instead of reading it as self.GetInput().GetPointData('v') and converting to numpy array later - it's the same syntax as the python calculator), but I don't know if it's possible to access the blocks of MultiBlockDataSet (I just found an example in http://kitware.com/blog/home/post/713 )

Ali_Sh
  • 2,667
  • 3
  • 43
  • 66
lib
  • 2,918
  • 3
  • 27
  • 53
  • 1
    Thanks very much! That's very helpful. I also figured out another way - self.GetOutputDataObject(0) is the output vtkMultiBlockDataSet - I just fill that. – Adam Mar 12 '15 at 04:09