Pcbnew scripting areas - net


#1

I’m trying to create a filled copper pour in pcbnew.
I can’t get AddArea or InsertArea to work because i can’t tell it what net to use.
Looking at http://docs.kicad-pcb.org/doxygen-python i need an integer, ideally from board.GetNetcodeFromNetname()
This doesn’t seem to exist in my script window or in my pcbnew.py file.
I don’t have GetNetsByName or GetNetsByNetcode either, not that they would help.
I do have FindNets, but it returns a structure that addarea or insertarea won’t accept and returns a single entry that has no name which is not correct, my named nets show up correctly in the GUI.

This is my first go at scripting but i haven’t had any trouble with moving components around or placing tracks.
I renamed my folder “python2.7\sitepackages” that contains pcbnew.py and reinstalled latest version but i’m still missing these functions.

can/should i just copy the stubs into my pcbnew.py file?

Thanks.


#2

What version of KiCad are you using? It does appear to be available in the nightly.

I see the following functions perform as expected:

import pcbnew
b=pcbnew.GetBoard()
n=b.GetNetsByNetcode()
b.GetNetcodeFromNetname('GND')

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

That documentation is auto-generated from latest source, so may not correspond to your installed version. I guess your installed version is older.

pcbnew.py tells you what is in your current version.

That sounds like a bad idea! The stubs must correspond to the kicad binary.


#4

4.0.6 (stable!) on Windows.
running nightly build now, works great, very different to what i was running.

of course i shouldn’t have just assumed i was up to date.

thanks.


#5

Now i can script an area but it won’t fill unless there is track inside.
If i draw it through the interface it fills without fuss.
There are pads inside the zone on the same net, just not track.

Is there any proper documentation for scripting? i need to learn the pcbnew source really!


#6

This appears to me to be the definitive documentation.


#7

There is also this relatively recent page:
http://docs.kicad-pcb.org/doxygen/md_Documentation_development_pcbnew-plugins.html