-
Notifications
You must be signed in to change notification settings - Fork 10
/
eagleexport
executable file
·75 lines (59 loc) · 1.63 KB
/
eagleexport
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python
import os
from eagle_automation.config import config
from eagle_automation.export import EaglePNGExport, \
EaglePDFExport, \
EagleGerberExport, \
EagleExcellonExport, \
EagleMountSMDExport
import sys
out_types = { 'png': EaglePNGExport,
'pdf': EaglePDFExport,
'gerber': EagleGerberExport,
'excellon': EagleExcellonExport,
'mountsmd': EagleMountSMDExport }
def usage():
print """eagleexport, export layers from CadSoft Eagle files
Copyright (C) 2013 Tomaz Solc <[email protected]>
USAGE: eagleexport input-file type output-file:layer ...
type can be any of %s
layer can be any of %s""" % (
', '.join(out_types.iterkeys()),
', '.join(config.LAYERS.iterkeys()) )
sys.exit(1)
def main():
if len(sys.argv) < 4:
usage()
in_path, out_type = sys.argv[1:3]
layers = []
out_paths = []
for arg in sys.argv[3:]:
try:
out_path, layer_name = arg.split(":")
except ValueError:
out_path = arg
layer_name = None
extension = in_path.split('.')[-1].lower()
if extension == 'brd':
if layer_name is None:
print "Layer name required when exporting brd files"
sys.exit(1)
try:
layer = config.LAYERS[layer_name]
except KeyError:
print "Unknown layer: " + layer_name
sys.exit(1)
elif extension == 'sch':
layer = {'layers': ['ALL']}
else:
print "Bad extension %s: Eagle requires file names ending in sch or brd" % extension
sys.exit(1)
layers.append(layer)
out_paths.append(out_path)
try:
export_class = out_types[out_type]
except KeyError:
print "Unknown type: " + out_type
sys.exit(1)
export_class().export(in_path, layers, out_paths)
main()