Created
October 12, 2019 10:31
-
-
Save 1f0/9559aa49f62ddf5fe92e5b94abfe348c to your computer and use it in GitHub Desktop.
convert obj to vtk file using python vtk lib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
if(len(sys.argv) != 3): | |
print('Usage: ', sys.argv[0], 'input.obj output.vtk') | |
sys.exit() | |
import vtk | |
reader = vtk.vtkOBJReader() | |
reader.SetFileName(sys.argv[1]) | |
reader.Update() | |
obj = reader.GetOutput() | |
writer = vtk.vtkPolyDataWriter() | |
writer.SetFileName(sys.argv[2]) | |
if vtk.VTK_MAJOR_VERSION <= 5: | |
writer.SetInput(obj) | |
else: | |
writer.SetInputData(obj) | |
writer.Write() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment