Kicad with scripting support

Hello,

I want to use python “import pcbnew” and in order to do that I need to install a kicad version supporting scripting. But looks like that the last stable version doesn’t support that, right? Where can I download the last stable version with python support?

Thanks

I just tried r7066, gives this at console ok

Py 0.9.8
Python 2.7.10 (default, Jul  8 2015, 15:10:39) 
[GCC 5.1.0] on win32
Type "help", "copyright", "credits" or "license" for more information.
Startup script executed: C:\Users\j\AppData\Roaming\kicad\PyShell_pcbnew_startup.py

then
execfile("C:\some\tests.py")
contains

import pcbnew   
pcb = pcbnew.GetBoard()

.. expected output...

but I did uncover a bug in one of my files, where I had coded

from pcbnew import * 
pcb = pcbnew.GetBoard()

that was tested, but I see is strictly incorrect, and needs a prior
import pcbnew

  • in my older tests, I must have done that in a session, and the console remembers that.
    Adds mental note to do a fresh-start test …

Well, actually what I want is to execute a file named: uipanelize.py that imports pcb new.

I have been investigating and I see that kicad includes a python 2.7 and all the libraries inside. If I execute python within the kicad folder I can import pcb without problem.

Is it possible to add pcbnew module into a external python 2.7 installation as a normal library?

When you talk a console… do you mean DOS console? or something working indide kicad?

Sorry is I make stupid questions but I am really new in Kicad and Kicad python scripting.

I would expect so, someone who has done this may advise.
From what you say, sounds like a simple path issue if it works from the included Python.

Why not use the installed Python ? , as you know it is installed with KiCad and thus reduces variables…
& you can access the same Python, from inside PcbNew.

Inside PcbNew, there is a launch Python Scripting Console button, top right >_ icon.

1 Like