Problem with Plugin Source with vtkImageData

This is a follow-up question to the one below:

I managed to create a vtkImageData in a Programmable Source.

Now I would like to pack this image creating in a Source plugin, as an alternative. So far, my RequestData method inside the MySource class (which extends VTKPythonAlgorithmBase) looks like:

def RequestData(self, request, inInfo, outInfo):

        output = vtkImageData.GetData(outInfo, 0)
        im = my_vtk_image

        # Setting image properties
        output.SetDimensions(im.nx, im.ny,
        output.SetSpacing(im.dx, im.dy,
        # This is necessary to update the output information
        executive = self.GetExecutive()
        outInfo0 = outInfo.GetInformationObject(0)
        outInfo0.Set(executive.WHOLE_EXTENT(), 0, im.nx-1, 0, im.ny-1, 0,
        outInfo0.Set(vtk.vtkDataObject.SPACING(), im.dx, im.dy,
        return 1

I manage to load this plugin but it doesn’t render the image in ParaView. The behaviour is similar to the one if I don’t set the extent of the image using the “executive”. Any clues on what might be going wrong? How to set the extent and spacing of the image when loading from a plugin source?

PS: How do I write block code here in the questions? Couldn’t find out.

Block code sections can be started with three backticks ``` on one line, the code, then three backticks on the last line.

As for your question, insert the method declaration

def RequestInformation(self, request, inInfoVec, outInfoVec):

before the code # This is necessary to update the output information

It needs to be defined in this other method so that it is called when the information is needed. That’s what the Programmable Source is doing under the covers when you define an Information sript.