Python classes overview with examples?

Hi there,
I’m at the task to get a plugin, that was built for KiCad6, to run in KiCad8.

The basic functionionality is iterating through a list of all footprints on the board and then checking for matches in some footprint attributes.
Executing the plugin throws this Attribute Error:

‘FOOTPRINT’ object has no attribute “GetProperties”

In the script there is a list generated with

for fp in self.board.GetFootprints():

and these “fp”-entries are separately read out with

mount = fp.GetTypeName()

if mount in ["SMD", "THT"]:
  if not "Mount" in fp.GetProperties():

And this last line generates the error.

In the Doxygen documentation I only get to this point but there is no explanation of how this list looks and a link to the details of the member list for “footprint”.

https://docs.kicad.org/doxygen-python-8.0/classpcbnew_1_1BOARD.html#a6805160088113d6a4ab900ea1b33cc70

Is there another overview for the API? Because I wasn’t able to locate any and also in the forum I didn’t get examples to fit my problem.

Footprint properties were merged into fields system.
Use fp.GetFieldsShownText() to get a map of properties.
https://docs.kicad.org/doxygen-python-8.0/classpcbnew_1_1FOOTPRINT.html#a060c61f20760219d56020c5b569836cf

There is no overview that I know of but you can get tons of examples from existing plugins you can find in the plugin manager.

There is an overview and some basic examples in the user manual: PCB Editor | 8.0 | English | Documentation | KiCad

I updated these for v8 (i.e. I updated them to make sure they worked correctly in 8.0.0) but I have limited experience with scripting KiCad so I can’t really speak to whether they’re the best way to do things or not.

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