Electronic – Command line interface for KiCAD


Is there a way to produce Gerber files from command line in KiCAD (Linux/Unix) or a tool which can do it for me? The same question for SPICE netlist and BOM xml?
I need it to automate this process within a CI-pipelie. GUI is not useable here.

Best Answer

It is possible to export Gerbers from Pcbnew with the Python Interface, as described here (with some adaption).

import pcbnew

# Load board and initialize plot controller
board = pcbnew.LoadBoard("<filename>.kicad_pcb")
pc = pcbnew.PLOT_CONTROLLER(board)
po = pc.GetPlotOptions()

# Set current layer

# Plot single layer to file
pc.OpenPlotfile("front_copper", pcbnew.PLOT_FORMAT_GERBER, "front_copper")
print("Plotting to " + pc.GetPlotFileName())

This can obviously be expanded to include all of the required layers for your output.

It's worth looking at the scripting reference to see if there's anything to help you further there.

Because netlists are handled by eeschema, it's unlikely you're going to be able to script that. Pcbnew can export BOMs, but it doesn't look like there is any way to export from the python interface.