Getting started with python scripting

I want to start using python scripting for the sake of learning.

There are a few things I want to use it for.

  • set silk texts of footprints
  • add fields to all schematic symbols properties.

I have googled for things but I cannot find that much.

I have found this video earlier today.

And this leads to my first question #1. I used pip to install the library, and it seems to work in python outside Kicad but ofcourse not in KiPython. How and where do I install libraries for KiPython

#2, other than being integrated in KiCad and containing pre-installed lbraries. Is there something special about KiPython in regards to regular python? Are there reasons why I really want to use KiPython instead of regular python?

#3 I used the library from the viedo to edit a schematic with some succes. Is there a native library in KiPyhton which can do the same? I only found a library to edit boards with

Kind regards :coffee:

Bas

To change silk texts of footprints, you would probably use pcbnew.py which acts as an API for kicad’s pcbnew program.

For changing symbol fields, you would have to use an external Python script to manipulate a kicad schematic or symbol library file. (This is what the kifield utility does.) There is currently no API for the schematic side of kicad.

For creating pcbnew plugins, there is a set of old tutorials written by a user https://kicad.mmccoo.com/. These can give you an outline of how to do it, but the pcbnew API has morphed since then so you’ll need to supplement it with newer material. Perhaps looking at some current plugin code would do that.

This (my video) shows Making a Basic ‘simple’ plugin. The Action (what it actually does isn’t important, the important part is getting the Structure correct so the Kicad will recognize it.

This is Not the newer ‘Official’ Plugin approach with Meta…etc. But, it still works by placing the xxx.py file into the User’s ‘Scripting’ folder…

I just made the Plugin shown in this Post so, the older process still works… The ‘Action’ your code does is up to you so, get a dumb-Action or just display some text to verify the Plugin process works, then do the real Action-Code…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.