Hi,
I’m trying to automate gerber generation of my kicad_pcb
file. I’ve followed instructions and troubleshooting on this forum.
It kinda almost works, but I don’t get the same plot for some layers when using it from the KiCad software using File > Plot
and python scripting.
Here is the python script I’m using:
board = pcbnew.LoadBoard ('power.kicad_pcb')
pctl = pcbnew.PLOT_CONTROLLER (board)
popt = pctl.GetPlotOptions ()
popt.SetOutputDirectory ('gerber_test'))
popt.SetPlotFrameRef(False)
popt.SetLineWidth(pcbnew.FromMM(0.1))
popt.SetAutoScale(False)
popt.SetScale(1)
popt.SetMirror(False)
popt.SetUseGerberAttributes(True)
popt.SetUseGerberProtelExtensions(True)
popt.SetExcludeEdgeLayer(True)
popt.SetUseAuxOrigin(False)
pctl.SetColorMode(True)
popt.SetSubtractMaskFromSilk(False)
popt.SetPlotReference(True)
popt.SetPlotValue(False)
layers = [
("F.Cu", pcbnew.F_Cu, "Top layer"),
("B.Cu", pcbnew.B_Cu, "Bottom layer"),
("F.Paste", pcbnew.F_Paste, "Paste top"),
("B.Paste", pcbnew.B_Paste, "Paste bottom"),
("F.SilkS", pcbnew.F_SilkS, "Silk top"),
("B.SilkS", pcbnew.B_SilkS, "Silk top"),
("F.Mask", pcbnew.F_Mask, "Mask top"),
("B.Mask", pcbnew.B_Mask, "Mask bottom"),
("Edge.Cuts", pcbnew.Edge_Cuts, "Edges"),
]
for layer_info in layers:
pctl.SetLayer (layer_info[1])
pctl.OpenPlotfile (layer_info[0], pcbnew.PLOT_FORMAT_GERBER, layer_info[2])
pctl.PlotLayer ()
pctl.ClosePlot()
With this script, and apart from Edge.Cuts also, every over layer (F.CU, etc.) is fine.
But I get the following. On the left is what File > Plot
gives, and on the right what the python script gives.
What’s happening? What’s wrong with my code?
I’m using KiCad Version 4.0.7 release build
Thanks,
Raphael