Difference between revisions of "Convert a File from LegacyVTK to VTI"

From KitwarePublic
Jump to: navigation, search
(Created page with "This program can be run with the pvpython executable that is distributed with ParaView <source lang="python"> import sys import paraview.vtk.io as ...")
 
Line 1: Line 1:
This program can be run with the [[ParaView/Python_Scripting|pvpython]] executable that is distributed with ParaView
+
This program can be run with the [[ParaView/Python_Scripting|pvpython]] executable that is distributed with ParaView. Note that this program directly uses low-level VTK classes, not high-level ParaView features.
  
 
<source lang="python">
 
<source lang="python">
Line 5: Line 5:
 
import paraview.vtk.io as vtk_io
 
import paraview.vtk.io as vtk_io
 
if len(sys.argv) < 2:
 
if len(sys.argv) < 2:
print "Useage\n\tpvpython vtk2vti.py FILE.vtk [more FILES.vtk...]\n"
+
print "Usage\n\tpvpython vtk2vti.py FILE.vtk [more FILES.vtk...]\n"
 
for arg in sys.argv[1:]:
 
for arg in sys.argv[1:]:
 
reader = vtk_io.vtkStructuredPointsReader()
 
reader = vtk_io.vtkStructuredPointsReader()

Revision as of 14:33, 16 October 2018

This program can be run with the pvpython executable that is distributed with ParaView. Note that this program directly uses low-level VTK classes, not high-level ParaView features.

import sys
import paraview.vtk.io as vtk_io
if len(sys.argv) < 2:
	print "Usage\n\tpvpython vtk2vti.py FILE.vtk [more FILES.vtk...]\n"
for arg in sys.argv[1:]:
	reader = vtk_io.vtkStructuredPointsReader()
	reader.SetFileName(arg)
	writer = vtk_io.vtkXMLImageDataWriter()
	writer.SetInputConnection(reader.GetOutputPort())
	output_filename = arg + ".vti"
	writer.SetFileName(output_filename)
	writer.Write()
	print "wrote to \"%s\"" % output_filename

back to ParaView/PythonRecipes.


ParaView: [Welcome | Site Map]