[python API] how to find which module is connected to each net


I’ve been trying to integrate replicatelayout.py from @mmccoo as an Action plugin.

With help of @HiGreg I’ve finished the UI part, but now I stumbled upon a new problem. To me it looks like the pcbnew Python API has changed since @mmccoo tested his script.

In order to replicate layout the script:

  1. does a lot of other things quite succesfully
  2. gets all nets via board.GetNetsByNetcode()
  3. gets all pads connected to each net via Pads method for each net (e.g. net.Pads()). And this is where I get an error "_AttributeError: ‘NETINFO__ITEM’ object has no attribute 'Pads’ "
  4. again a lot of other things

As I look on Tutorials on python scripting in pcbnew the Net class used to have Pads() method. But from what I can tell from the current Python API documentation at KiCAD pcbnew scripting the Net class does no longer have this method.

I probably might be able to jerry rig the script to get the modules and nets associated to them via pads class as its members have GetNet() and GetNetname() and I can find to which Module they belong to via GetParent(), but before I delve to deep for my comfort I would like to know:


  1. Can anybody confirm that pcbnew python API changed, and Net class does no longer have Pads() method?
  2. How stable is Python API (if I make something and publish it, how much will the support for the thing take in the long run)?
  3. Is there any other direct way to find pads (or even better modules) that are connected to one net?


pcbnew python API changes over time. 4.0.7 is slightly different from nightly.

Have a look at this thread about python and nets