diff --git a/KiCAD/Makefile b/KiCAD/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..d7c0506dcc273da5a26ec02bd994e8bcf0561220 --- /dev/null +++ b/KiCAD/Makefile @@ -0,0 +1,11 @@ +# Create fab files. + +PocketBeagle-fab.zip: + +%-fab.zip : %-fab.kicad_pcb + python ../kicad-scripts/kicad-fab.py $< plot/ + zip -r $@ plot/ + +# Replacing any %%gitversion%% with a github version string. +%-fab.kicad_pcb : %.kicad_pcb + sed "s/%%gitversion%%/`git log --date=short --pretty=format:'%h@%cd' -n 1 $^`/" < $^ > $@ diff --git a/kicad-scripts/kicad-fab.py b/kicad-scripts/kicad-fab.py new file mode 100644 index 0000000000000000000000000000000000000000..110865826f74b3c3504723f66775262788fa8ae5 --- /dev/null +++ b/kicad-scripts/kicad-fab.py @@ -0,0 +1,96 @@ +''' + H. Zeller <h.zeller@acm.org> + Based on gen_gerber_and_drill_files_board.py in kicad/demos directory. +''' + +import sys +import os + +from pcbnew import * +filename=sys.argv[1] +plotDir = sys.argv[2] if len(sys.argv) > 2 else "plot/" + +board = LoadBoard(filename) + +plotDir = "plot/" + +pctl = PLOT_CONTROLLER(board) + +popt = pctl.GetPlotOptions() + +popt.SetOutputDirectory(plotDir) + +# Set some important plot options: +popt.SetPlotFrameRef(False) +popt.SetLineWidth(FromMM(0.35)) + +popt.SetAutoScale(False) +popt.SetScale(1) +popt.SetMirror(False) +popt.SetUseGerberAttributes(True) +popt.SetUseGerberProtelExtensions(True) +popt.SetExcludeEdgeLayer(True); +popt.SetScale(1) +popt.SetUseAuxOrigin(True) + +# This by gerbers only (also the name is truly horrid!) +popt.SetSubtractMaskFromSilk(False) + +# param 0 is the layer ID +# param 1 is a string added to the file base name to identify the drawing +# param 2 is a comment +# Create filenames in a way that if they are sorted alphabetically, they +# are shown in exactly the layering the board would look like. So +# gerbv * +# just makes sense. The drill-file will be numbered 00 so that it is first. +plot_plan = [ + ( Edge_Cuts, "01-Edge_Cuts", "Edges" ), + + ( F_SilkS, "02-SilkTop", "Silk top" ), + ( F_Paste, "03-PasteTop", "Paste top" ), + ( F_Cu, "04-CuTop", "Top layer" ), + ( F_Mask, "05-MaskTop", "Mask top" ), + + ( In1_Cu, "06-CuIn1", "Inner Layer1" ), + ( In2_Cu, "07-CuIn2", "Inner Layer2" ), + + ( B_Mask, "08-MaskBottom", "Mask bottom" ), + ( B_Cu, "09-CuBottom", "Bottom layer" ), + ( B_Paste, "10-PasteBottom", "Paste Bottom" ), + ( B_SilkS, "11-SilkBottom", "Silk top" ), +] + + +for layer_info in plot_plan: + pctl.SetLayer(layer_info[0]) + pctl.OpenPlotfile(layer_info[1], PLOT_FORMAT_GERBER, layer_info[2]) + pctl.PlotLayer() + +# At the end you have to close the last plot, otherwise you don't know when +# the object will be recycled! +pctl.ClosePlot() + +# Fabricators need drill files. +# sometimes a drill map file is asked (for verification purpose) +drlwriter = EXCELLON_WRITER( board ) +drlwriter.SetMapFileFormat( PLOT_FORMAT_PDF ) + +mirror = False +minimalHeader = False +offset = wxPoint(0,0) +mergeNPTH = True # non-plated through-hole +drlwriter.SetOptions( mirror, minimalHeader, offset, mergeNPTH ) + +metricFmt = True +drlwriter.SetFormat( metricFmt ) + +genDrl = True +genMap = True +drlwriter.CreateDrillandMapFilesSet( plotDir, genDrl, genMap ); + +# We can't give just the filename for the name of the drill file at generation +# time, but we do want its name to be a bit different to show up on top. +# So this is an ugly hack to rename the drl-file to have a 0 in the beginning. +base_name = filename[:-10] +print plotDir + base_name + ".drl" +os.rename(plotDir + base_name + ".drl", plotDir + base_name + "-00.drl")