Last active
April 1, 2017 21:10
-
-
Save TechplexEngineer/af6115adaa44567a1723 to your computer and use it in GitHub Desktop.
Easily prepare gEDA PCB layouts for OSH Park.
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
| TARGET = control | |
| .phony: all clean gerber | |
| all: | |
| gsch2pcb --elements-dir "../pcb-elements" project | |
| clean: | |
| rm -f *.net *.cmd | |
| rm -rf gerber | |
| rm -f *~ *- *.backup | |
| gerber: | |
| mkdir -p gerber | |
| cp $(TARGET).pcb gerber/ | |
| cd gerber/; pcb -x gerber --all-layers $(TARGET).pcb | |
| renamepcb gerber | |
| zip $(TARGET).zip gerber/* |
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
| #!/usr/bin/env python | |
| import os, re, sys | |
| where = '.' | |
| try: | |
| where = sys.argv[1] | |
| except: | |
| pass | |
| # Maps the euffix of the filename to the OSHPark format | |
| layerMapping = { | |
| "F_Cu.gbr": "gtl", | |
| "B_Cu.gbr": "gbl", | |
| "F_Mask.gbr": "gts", | |
| "B_Mask.gbr": "gbs", | |
| "F_SilkS.gbr": "gto", | |
| "B_SilkS.gbr": "gbo", | |
| "Edge_Cuts.gbr": "gko", | |
| 'drl': "xln" | |
| } | |
| pattern = re.compile(r'^(?P<basename>.*)-(?P<ident>[^-]*)$') | |
| p2 = re.compile(r'^(?P<basename>.*)\.(?P<ident>.*)$') | |
| os.chdir(where) | |
| for filename in os.listdir('.'): | |
| match = False | |
| if filename.endswith(".gbr"): | |
| match = re.search(pattern,filename) | |
| elif filename.endswith(".drl"): | |
| match = re.search(p2,filename) | |
| if match: | |
| newFilename = match.group('basename')+'.'+layerMapping[match.group('ident')] | |
| print 'Renaming \'{0}\' to \'{1}\''.format(filename, newFilename) | |
| os.rename(filename, newFilename) | |
| else: | |
| print 'No match.', filename | |
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
| #! /usr/bin/python | |
| import os, re, sys | |
| layerMapping = { | |
| "top": "gtl", | |
| "bottom": "gbl", | |
| "topmask": "gts", | |
| "bottommask": "gbs", | |
| "topsilk": "gto", | |
| "bottomsilk": "gbo", | |
| "plated-drill": "drl",### DIFFERENT EXTENSION | |
| "group2": "g2", | |
| "group3": "g3", | |
| "toppaste": "gtp", | |
| "bottompaste": "gbp", | |
| "outline": "outline", | |
| } | |
| where = '.' | |
| try: | |
| where = sys.argv[1] | |
| except: | |
| pass | |
| pattern = re.compile(r'^(?P<basename>[^\.]*)\.(?P<layer>[^\.]*)\.(?P<ext>(gbr)|(cnc))$') | |
| os.chdir(where) | |
| for filename in os.listdir('.'): | |
| if filename.endswith(".gbr") or filename.endswith(".cnc"): | |
| match = re.search(pattern,filename) | |
| if match: | |
| if match.group('layer') in layerMapping: | |
| newFilename = match.group('basename')+'.'+match.group('layer')+'.'+layerMapping[match.group('layer')] | |
| print 'Renaming \'{0}\' to \'{1}\''.format(filename, newFilename) | |
| os.rename(filename, newFilename) | |
| else: | |
| print 'No match.', filename | |
| sys.exit(0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment