# Error in save vtkParametricFunctionSource using vtkPolyDataWriter

**URL:** https://discourse.vtk.org/t/error-in-save-vtkparametricfunctionsource-using-vtkpolydatawriter/9315
**Category:** Support
**Tags:** python
**Created:** [September 11, 2022, 1:12am UTC](https://discourse.vtk.org/t/error-in-save-vtkparametricfunctionsource-using-vtkpolydatawriter/9315 "2022-09-11T01:12:56Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zhen\_tian](https://discourse.vtk.org/user_avatar/discourse.vtk.org/zhen_tian/32/5757_2.png) [@zhen\_tian](https://discourse.vtk.org/u/zhen_tian)
#### Post date: [September 11, 2022, 1:12am UTC](https://discourse.vtk.org/t/error-in-save-vtkparametricfunctionsource-using-vtkpolydatawriter/9315/1 "2022-09-11T01:12:56Z")

</div>

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.

```auto
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.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [September 12, 2022, 1:00pm UTC](https://discourse.vtk.org/t/error-in-save-vtkparametricfunctionsource-using-vtkpolydatawriter/9315/2 "2022-09-12T13:00:23Z")

</div>

Your example works perfectly for me, creating a .vtk file with this polydata:

![image](https://discourse.vtk.org/uploads/default/original/2X/2/21bc796bf61aa2bcfea385d86cb86fa227657197.png)

The `SetInputData argument 1: method requires a VTK object` error message indicates that VTK has not been imported correctly into your Python environment. If you provide more information about how did you get VTK (did you build it or pip-installed), which VTK and Python distribution and version you used, etc. then `dgobbi` or `ben.boeckel` may be able to help you.

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [September 15, 2022, 2:12am UTC](https://discourse.vtk.org/t/error-in-save-vtkparametricfunctionsource-using-vtkpolydatawriter/9315/3 "2022-09-15T02:12:09Z")

</div>

I can also confirm that it works for me. You most likely need to set up your Python environment.
