# Write file in vtk format

**URL:** https://discourse.vtk.org/t/write-file-in-vtk-format/3964
**Category:** Support
**Tags:** file-formats
**Created:** [August 13, 2020, 10:21am UTC](https://discourse.vtk.org/t/write-file-in-vtk-format/3964 "2020-08-13T10:21:04Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Yakov](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yakov/32/2190_2.png) [@Yakov](https://discourse.vtk.org/u/Yakov)
#### Post date: [August 13, 2020, 10:21am UTC](https://discourse.vtk.org/t/write-file-in-vtk-format/3964/1 "2020-08-13T10:21:04Z")

</div>

I want to create vtk file with mesh  
The vtk should have :

# vtk DataFile Version 3.0

```
POINTS 
POLYGONS 
NORMALS

```

I create a 3d cube object

```
cube1 = vtk.vtkCubeSource()
cube1.SetXLength(6)
cube1.SetYLength(10)
cube1.SetZLength(4)
cube1.SetCenter(0,2,0)
cube1.Update()

```

How do I save it in required format?  
I tried this

```
 writer = vtk.vtkPolyDataWriter()
 writer.SetInputData(cube1.GetOutput())
 writer.SetFileName('cube1.vtk')
 writer.Update()

```

This is another format (it has OFFSETS / CONNECTIVITY)  
I tried this

```
writer = vtk.vtkUnstructuredGridWriter()
writer.SetFileName("Cube1.vtk")
writer.SetInputData(cube1.VTKObject)
writer.Write()

```

I get an error : no attribute ‘VTKObject’  
I have asked the same question on stack([https://stackoverflow.com/questions/63391179/write-file-in-vtk-format](https://stackoverflow.com/questions/63391179/write-file-in-vtk-format))
