I was recently asked on the kicad.info forum¬†how to create a new netclass. It was already possible to modify existing ones, but the constructor for new ones hadn’t been exposed to the python interface. I’ve submitted the change to the kicad folks and it’s in the nightly builds.
Even with the constructor exposed, the sequence of steps to get to it isn’t obvious.
import pcbnew
board = pcbnew.GetBoard()
ds = board.GetDesignSettings()
# ugly. exposes a public member not via an accessor method
nc = ds.m_NetClasses
foo = pcbnew.NETCLASSPTR("foo")
The nc variable (NETCLASSPTR) has lots of useful get’er set’er functions, like SetClearance, SetTrackWidth. These are easy to find in the python window. Just type “foo.” and you should get a popup of available functions. You can also run the function “dir(foo)”

Modify design rules from python

One thought on “Modify design rules from python

  • April 18, 2017 at 10:08 am

    Nice, this is very handy. Do you have an opinion on wrapping these functions in a more user friendly interface?


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.