DRC from Python Scripting

Hi,

I was looking for a way to do DRC on Python Scripting but neither in the forum or here https://docs.kicad.org/doxygen-python/namespaces.html I find if it is possible or not.

Is is possible?

Thank you

I cannot claim that I know all the possibilities of python scripting but I’m pretty sure you can’t run DRC from python.

I searched inside python API and didn’t find any way to run drc either. There is no mapping for DRC_RUNNER classes.
Depending on what you intend to achieve, there is another way to run DRC by commandline.

To do so you will need to have qa_pcbnew_tools built.
Documentation on that subject is quite ligth : https://docs.kicad.org/doxygen/md_Documentation_development_testing.html
Binary is not packaged (at least under ubuntu and windows)
I built from source to get it (option “KICAD_BUILD_QA_TESTS” must be enabled)

Then you are able to run a DRC on a kicad_pcb file :

qa/pcbnew_tools/qa_pcbnew_tools drc FILE.kicad_pcb -t -m -v -A
Running DRC check: Courtyard overlap
Running DRC check: Courtyard missing

3 Likes

You could possibly navigate the GUI in Python. Missing Functions on python API

This lib is using this method : https://github.com/productize/kicad-automation-scripts
But like you said, this is really dependent on GUI changes.

Some news on that subject if anyone is interested in :

  • DRC system is in complete rebuild that is going to the right direction (GUI/logic separation)
    https://gitlab.com/kicad/code/kicad/-/issues/2030
    I don’t know when it will be available.

  • waiting for that, I had the need to run DRC checks from commandline or python.
    Current qa_pcbnew_tools doesn’t run all DRC available from HMI, only courtyard missing/overlap.
    I made a fork splitting DRC classes and making all DRC available in qa_pcbnew_tools (option “-d” or “-A”).
    If anyone is interested, sources are there : https://gitlab.com/GuiCod/kicad
    As it won’t be integrated in product as-is, it is only a temporary bypass. (provided as-is)

1 Like

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