Convert UnstructuredGrid data to PolyData and then to ImageData

here is my main function:


here is my PolyDataToImageData function:


An error occurred at the terminal:

I hope someone can help me!