Search code examples
pythonsavevtk

Save in VTK old format 3.0


I want to create vtk file with mesh(I use vtk 9) 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()

I got format 5.1 but I need the old one.If there is any way to get old format?(Except using old version of vtk)


Solution

  • VTK does not allow to select an old format, so VTK 9 can only write legacy files in version 5.1.