summaryrefslogtreecommitdiff
path: root/import_tools/iges2stl.py
blob: fa29ccbae75fad499f13054d49da0b8c8ebbc28c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
#iges2stl in.iges out.stl
'''
iges2stl in.iges out.stl
converts from IGES to STL
'''
import sys
from OCC.Utils.DataExchange.IGES import IGESImporter
from OCC.Utils.DataExchange.STL import STLExporter
from OCC.BRepPrimAPI import *
from OCC.StlAPI import *

iges_file = sys.argv[1]
stl_file = sys.argv[2]

print "iges2stl: loading iges file"

my_iges_importer = IGESImporter(iges_file)
my_iges_importer.ReadFile()
the_shapes = my_iges_importer.GetShapes()
main_shape = the_shapes[0]

#Export to STL. If ASCIIMode is set to False, then binary format is used.
#my_stl_exporter = STLExporter(stl_file,ASCIIMode=True)
#my_stl_exporter.SetShape(the_compound)
#my_stl_exporter.WriteFile()

print "iges2stl: saving as stl"

stl_exp = StlAPI()
stl_exp.Write(main_shape, stl_file)

print "iges2stl: done"