How to create "Footprint Position" file with


For MSEkicadBOM

I need to create the same output as by pcbnew ‘File’-‘Fabrication Outputs’-‘Footprint Position (.pos) File’. I was told that it is possible “with a few lines of Python Code”. I learned that not all functions in are working or are intended to be used. So I dare to ask here first before I again spend days with and doubtful results. Does anybody know how it can be achieved?

Thanks, Martin


Yes, a simple example would help. Can someone please post one?


With KiCommand, you can get the center positions with the following command:

modules GetCenter call print

Edit to add: the new KiCommand makes it easy to use KiCommand within python. By default the function returns the top of the stack, so you would get, in this case, a list of the center wxPoints of the modules. So you can run:"modules GetCenter call")

In python after import kicommand.


Thanks, but not really what I wanted.

I already have a Python program that autodetects changes and produces gerbers and PDFs for a series of PCBs, I just want to add position export.

(I appreciate people contributing, but installing and learning a completely new tool for this simple task—I’d rather spend the time learning the Python interface.)


Steps in python:

import pcbnew
for m in pcbnew.GetBoard().GetModules():
    c = m.GetCenter()
    print m.GetReference(), c.x, c.y

And replace the print statement with any formatting you need. (I can’t remember whether GetReference() returns the text and Reference() returns the EDA_TEXT or vice versa.)


Excellent, many thanks!

Exactly what I needed, and very very simple.