KiCad Plugin With Python


Preparation

โœ… Install KiCad
โœ… Python & wxPython knowledge

Quick Start

โฆฟ Create a blank project โ–ท Open "PCB Editor" โ–ท Click "Show the Python scripting console".
KiCad Plugin
โฆฟ Enter the following command at "2".
>>> import wx โ†ฉ๏ธ
>>> wx.MessageBox("Hello World") โ†ฉ๏ธ
KiCad Plugin

Create A Hello World Plugin

โฆฟ Create a Hello_World.py file.
โฆฟ Enter the following code.
import pcbnew
import os
import wx

class SimplePlugin(pcbnew.ActionPlugin):
    def defaults(self):
        self.name = "Hello World"
        self.category = "A descriptive category name"
        self.description = "A description of the plugin and what it does"
        self.show_toolbar_button = False # Optional, defaults to False
       
    def Run(self):
        # The entry function of the plugin that is executed on user action
        wx.MessageBox("Hello World")

SimplePlugin().register() # Instantiate and register to Pcbnew
โฆฟ put it in:
    Windows: ...\Documents\KiCad\6.0\scripting\plugins\
    MacOS: .../Documents/KiCad/6.0/scripting/plugins/
โฆฟ Open PCB Editor โ–ท Tools โ–ท External Plugins โ–ท Hello World
KiCad Plugin
Show "Hello World" OK โ†ฉ๏ธ
KiCad Plugin

Resource