It took a bit or experimenting to figure out and mine was based on this sites:
- http://scottbezek.blogspot.com/2016/04/ ... ports.html title says it all
- https://docs.kicad.org/5.1/en/pcbnew/pc ... ction_menu how to create a KiCAD plug-in
The Python 2.7 (used by KiCAD 5.1) script that does the export:
Code: Select all
import pcbnew
import os
class SimplePlugin(pcbnew.ActionPlugin):
def defaults(self):
self.name = "Export Stencil"
self.category = "Stencil Exporter"
self.description = "This will export the Front Paste layer as a SVG file"
self.show_toolbar_button = True # Optional, defaults to False
self.icon_file_name = os.path.join(os.path.dirname(__file__), 'Stencil.png') # Optional, but needs to be a 26x26px png file
def Run(self):
# The entry function of the plugin that is executed on user action
# Load board and initialize plot controller
board = pcbnew.GetBoard() # where to get the current board name from?
pc = pcbnew.PLOT_CONTROLLER(board)
po = pc.GetPlotOptions()
po.SetPlotFrameRef(False)
# Set current layer
pc.SetLayer(pcbnew.F_Paste) # only export the front paste layer
print("step 1")
# Plot single layer to file
pc.OpenPlotfile("front_paste", pcbnew.PLOT_FORMAT_SVG, "front_paste")
print("step 2")
print("Plotting to " + pc.GetPlotFileName())
pc.PlotLayer()
pc.ClosePlot()
print("Finished")
SimplePlugin().register() # Instantiate and register to Pcbnew
When run, the script will export the PCBNew Front Paste layer as a SVG file and place it in the projects folder. I then import the file into Lightburn software so I can raster etch my plastic stencil: viewtopic.php?f=12&t=2454 This works really well for my projects.