I am working on a project which need to save data into .vtk file using python. I got an error when save a vtkParametricFunctionSource. Here is a sample code.
import vtk
ellipsoid = vtk.vtkParametricEllipsoid()
ellipsoid.SetXRadius(1)
ellipsoid.SetYRadius(1)
ellipsoid.SetZRadius(1)
ellipsoidSource = vtk.vtkParametricFunctionSource()
ellipsoidSource.SetParametricFunction(ellipsoid)
ellipsoidSource.SetOutputPointsPrecision(5)
ellipsoidSource.Update()
writer = vtk.vtkPolyDataWriter()
writer.SetInputData(ellipsoidSource.GetOutput())# fail
# writer.SetInputConnection(ellipsoidSource.GetOutputPort()) # also fail and get same result
writer.SetFileName('ellipsoid.vtk')
writer.Update()
The program report:‘SetInputData argument 1: method requires a VTK object’. I cannot figure out the reason behind it. Please help me, thanks.