← Back to team overview

kicad-developers team mailing list archive

Calling pcbnew's DRC from Python Scripting API?

 

Hello,

I'm trying to figure out how to run the DRC in pcbnew from the Python
Scripting API. I've managed to get API into an iPython session (
https://github.com/mithro/kicad-length-matching-checks/blob/master/ipython.py)
to have a poke around but wasn't able to find the right function to call.

It looks like if I can get the DRC to run, there seems to be an API for
accessing the marker's it adds to the board which exposes
https://github.com/KiCad/kicad-source-mirror/blob/master/pcbnew/class_marker_pcb.h

GetMARKER(self, *args) method of pcbnew.BOARD instance
    GetMARKER(BOARD self, int index) -> MARKER_PCB

GetMARKERCount(self) method of pcbnew.BOARD instance
    GetMARKERCount(BOARD self) -> int

I did find, board.Test_Drc_Areas_Outlines_To_Areas_Outlines - but couldn't
figure out how to call it, or if it did what I wanted.

Test_Drc_Areas_Outlines_To_Areas_Outlines(self, *args) method of
pcbnew.BOARD instance
    Test_Drc_Areas_Outlines_To_Areas_Outlines(BOARD self, ZONE_CONTAINER
aArea_To_Examine, bool aCreate_Markers) -> int


There also seems to be the pcbnew.DRC_VISIBLE constant, but I couldn't find
where that might be used.

I had a dig around the KiCad source in the scripting directory, and the
other files with DRC in their name but didn't see anything similar mapped
into the API (but maybe I'm looking in the wrong area?)

Does anyone know how to cause the DRC to run from the Python scripting API?
(Or if it isn't currently exposed, the correct functions to expose via
SWIG?)

Thanks for your help!

Tim 'mithro' Ansell