Making a good assembly drawing for hand soldering out of the KiCAD PCBNew


A long time ago I wrote a script for making color-coded hand assembly drawings (see attached PDFfreewatch_assy.pdf (205.3 KB) ) from Gerber/BOM files produced by Kicad.

The code is here:

If somebody finds it useful, maybe we’ll integrate it more with Kicad.



Hi, Tom!
The drawing that goes out of your script is wonderful!
But I didn’t get the idea how to implement it. Is is definitely written in Python (as it has .py extension). But I don’t know this language and don’t know how to execute one.
Is there any additional recommendations?

Tom scripts looks nice.

@Roman_Matveev Kicad can export to lots of formats types the gerbers. I did something similar I exported to SVG and then I edit it with Inkscape and draw the things as I want.

Tom! I downloaded and installed Python for Windows from its official website, version 3.5.
So now I can run you script (BTW: which script will do the job - or but the window opened for a second or so and then disappeared. But it was pretty expected as I did not feed the gerbers to it.
Could you explain how to use your scripts?

Thank you for your great job!

What we usually do is plot the silkscreen and the board edge as SVG, resize it, and save it as PDF.
Certainly not as good as the script above, but decent enough if your footprints have the reference and the component orientation in the silkscreen.

Everybody is assembling boards he?

Just came up with this version to get greyscale board overviews for hand-assembly.

What I really miss now is the option to have a Top and Bottom user layer, where I could put the REF** value on. Currently it resides on Eco1, but this doesn’t work as Top/Bottom and I get both layers REF values on the printout…

Or the footprints would need to allow me to set the layer assignment for REF/VAL to more than one layer… that would work too…

Anyhow, my current method is described here:

1 Like

Hmm, I haven’t run the scripts, but looking at it I would guess you need to do the following:

  • Generate a pick and place file from kicad. Make sure its filename is exactly the same as the KiCad gerbers you made (so if the gerbers are ProjectBunny.GBO, ProjectBunny.GTL, etc the pick and place data should be ProjectBunny.csv)
  • Open a terminal and run the program and as the argument give it the project name (e.g. ProjectName) and it should spit out a pdf with that same project name. e.g. python ProjectBunny
1 Like

Hi everybody

I tried to use

Big problem :

python myboard

File “”, line 3, in

from gerber2pdf import *
File “/home/jean/Télechargements/assygen-master/kicad-test/”, line 304, in
class GerberScanner(Scanner):
NameError: name ‘Scanner’ is not defined

May be a problem of librairie ?

Jean Pierre

I read the code/documentation to determine: the name ‘Scanner’ probably should be defined by the ‘plex’ python module, which is imported earlier in So maybe there is a problem with your plex module, which you probably downloaded. The import of plex apparently succeeded, so maybe it is a name clash, where another module named plex exists? You could hack the code near the ‘import plex’ statement to determine more information.

Recently I was looking for that kind of tool as well. Joan_Sparky also pointed me at this post and in the end started writing a small python script for plotting assembly drawings. It uses the KiCad API to read the pcb file and draws pick and place maps with matplotlib.

The python code for the Pick and Place Assistant is uploaded as GitHub Gist if anyone is still interested. Some plotting capabilities and optimizations are missing but it does the job for now. Feel free to pick it up for own use, extend/modify it, etc.

Example output:


Impressive screenshot results. Could you just write some guidelines how to use your script?
I am a linux user and install KiCAD from sources.
Lets assume I don’t know what python is, how can I make it work magically? :open_mouth:

It has a command line interface, so just run it with python or make it executable and call it directly. The first argument should be the kicad pcb file.
pyhton board.kicad_pcb or ./ board.kicad_pcb

It requires the matplotlib and kicad libraries for python. If your KiCad from source installation took care of putting the python modules at the right place you should be good to go (if matplotlib is installed too).

1 Like

Nice tool, I wrote one based on the old BRD file format and found this in my quest to do less code writing and more designing. First, Python is not my forte. I’ve written some things in it, but cant say I’m very good at it. That being said, I’m running this in Linux (Ubuntu 16.04), I think all the libs are installed but I get the following errors when I run the code on a simple board a made last week. PiCAN360.kicad_pcb
Loading PiCAN360.kicad_pcb
Traceback (most recent call last):
File “/home/rhowlett/Dropbox/bin/kicad_scripts/”, line 158, in
bom_table = generate_bom(pcb, filter_layer=pcbnew.F_Cu)
File “/home/rhowlett/Dropbox/bin/kicad_scripts/”, line 127, in generate_bom
group_key = (m.GetValue(), str(m.GetFPID().GetFootprintName()))
File “/usr/lib/python2.7/dist-packages/”, line 4023, in
getattr = lambda self, name: _swig_getattr(self, LIB_ID, name)
File “/usr/lib/python2.7/dist-packages/”, line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File “/usr/lib/python2.7/dist-packages/”, line 69, in _swig_getattr_nondynamic
return object.getattr(self, name)
AttributeError: type object ‘object’ has no attribute ‘getattr

I’m a little lost on what its barffing on sinceAny help would be great!

Here is a little more info:

head /usr/lib/python2.7/dist-packages/

This file was automatically generated by SWIG (

Version 3.0.8

First question, is the correct version of

The version number from the header belongs to SWIG, I can’t find the real KiCad version number in this file. My guess is that you are using different/older KiCad bindings. I wrote/tested this script using Ubuntu and the KiCad PPA (KiCad 4.0.4).

1 Like

I have the same problem like Richard.

AttributeError: type object ‘object’ has no attribute ‘getattr’

I’m using LinuxMint 18 (16.04 Ubuntu) 64bit.
with the nightlybuild KiCad-Version.
deb xenial main

Is there a soluton for using this great tool ?
The file in usr/lib/python2.7/dist-packages/ is replaced by every nightly build.
And it’s the only file with this name on my system.

Loading board.kicad_pcb
Traceback (most recent call last):
File “”, line 166, in
bom_table = generate_bom(pcb, filter_layer=pcbnew.F_Cu)
File “”, line 135, in generate_bom
group_key = (m.GetValue(), str(m.GetFPID().GetFootprintName()))
File “/usr/lib/python2.7/dist-packages/”, line 4357, in
getattr = lambda self, name: _swig_getattr(self, LIB_ID, name)
File “/usr/lib/python2.7/dist-packages/”, line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File “/usr/lib/python2.7/dist-packages/”, line 69, in _swig_getattr_nondynamic
return object.getattr(self, name)
AttributeError: type object ‘object’ has no attribute ‘getattr

The problem you are seeing is caused by an API change in the KiCad development branch, while the script was developed using the latest KiCad stable release.

I just switched to the nightly PPA release too and adapted the Pick and Place script. It should work with KiCad 4 and the current development branch alike. If you want you can give it another try, just go to the linked github gist from above and fetch the updated revision.

Ping: @ado, @kammutierspule, @Richard_Howlett


It’s working with the nightly build.
I get messages of “Unsupported pad shape” because i use some rounded pads.
Shape 3 and 4 are not implemented in the python script, I saw,
but the areas of the parts are marked good enough to be happy.
It would be great if in the far, far future rounded pads are supported too.
And none rectagle pcb-outline-forms are displayed with roundings and so on.
Thank you so much for this great useful script.
It should be inbuild in next stable Kicad release.

I’ve been playing with the script so I can use it as part of my documentation flow. I’ve added a few extras like location of pin 1 on footprints and putting an outline on each part. However, the outline is using the GetSize and that doesn’t work very well for 45 degree rotated parts and mounting holes with other parts within that envelope. I can’t find a simple way to draw one of the layers like T_SilkS. I’ve been using the for documentation. Is there better documentation to describe some of the functions? Also, navigation in doxygen is killing me. Trying to hunt down what variables are valid with most of the functions it painful. (ok, I’m just venting a little). Anyway, I was thinking about taking a slightly different approach. I think I could generate and SVG or PDF in a separate file using the PLOT functions, then overlay the pads and info on that SVG or PDF image at the end of each page generation. Unfortunately, I don’t use python that much so there is a steep learning curve, but I’m sure it would work. Has anyone looked at doing it this way? I’m sure I’m not realizing a reason it will not work:)

Wow this looks awesome considering it’s automated by the software.
realy why not integrate it to kicad?

And yeah sore for bringing this dead cat from the grave.

Installing NumPy is problematic in KiCad python because a “normal” install of NumPy requires compilation. Users would have to set up the ability to compile C++ I.e. using mingw). There are pre -compiled versions of NumPy that are supposed to work, but I have been unable to get them installed on Windows.

I’d love for NumPy to be installed with KiCad python by default for DRC purposes (see KiPadCheck).

This tool might be able to be refactored for use with hand-written SVG overlay output so that additional python libraries are not needed.