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:
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 assygen.py ProjectBunny
Hi everybody
I tried to use assygen.py.
Big problem :
python assygen.py myboard
File “assygen.py”, line 3, in
from gerber2pdf import *
File “/home/jean/Télechargements/assygen-master/kicad-test/gerber2pdf.py”, 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 gerber2pdf.py. 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.
Hi!
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?
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 script.py board.kicad_pcb
or ./script.py 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).
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.
kicad_picknplace_assistant.py PiCAN360.kicad_pcb
Loading PiCAN360.kicad_pcb
Traceback (most recent call last):
File “/home/rhowlett/Dropbox/bin/kicad_scripts/kicad_picknplace_assistant.py”, line 158, in
bom_table = generate_bom(pcb, filter_layer=pcbnew.F_Cu)
File “/home/rhowlett/Dropbox/bin/kicad_scripts/kicad_picknplace_assistant.py”, line 127, in generate_bom
group_key = (m.GetValue(), str(m.GetFPID().GetFootprintName()))
File “/usr/lib/python2.7/dist-packages/pcbnew.py”, line 4023, in
getattr = lambda self, name: _swig_getattr(self, LIB_ID, name)
File “/usr/lib/python2.7/dist-packages/pcbnew.py”, line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File “/usr/lib/python2.7/dist-packages/pcbnew.py”, 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/pcbnew.py
This file was automatically generated by SWIG (http://www.swig.org).
Version 3.0.8
First question, is the correct version of pcbnew.py?
The version number from the pcbnew.py
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).
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 http://ppa.launchpad.net/js-reynaud/ppa-kicad/ubuntu xenial main
Is there a soluton for using this great tool ?
The pcbnew.py 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 “kicad_picknplace_assistant.py”, line 166, in
bom_table = generate_bom(pcb, filter_layer=pcbnew.F_Cu)
File “kicad_picknplace_assistant.py”, line 135, in generate_bom
group_key = (m.GetValue(), str(m.GetFPID().GetFootprintName()))
File “/usr/lib/python2.7/dist-packages/pcbnew.py”, line 4357, in
getattr = lambda self, name: _swig_getattr(self, LIB_ID, name)
File “/usr/lib/python2.7/dist-packages/pcbnew.py”, line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File “/usr/lib/python2.7/dist-packages/pcbnew.py”, 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 http://docs.kicad.org/doxygen-python 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.
seems more documentation tools would benefit from a modified SVG-Export
at group-g-elements-by-netlist-in-plotted-svg
and also at proof-of-concept-web-based-svg-design-viewer
this was discussed…
Is someone here that has time to look into this
or i have to find the time to have a look at how hard it is to get into kicad modifications myself
but this will take time…
sunny greetings stefan
I took the presence of NumPy for granted, but if this gives Windows users too much of a headache we could just remove this dependency. I didn’t use it for technical reasons (like computation time or storage), I just like using NumPy for more convenient linear algebra coding.
I’m kind of astonished though that nobody talked about the elephant in the room, the dependency on matplotlib
for doing the drawing :D.
The idea of putting everything in the browser is interesting of course. Instead of emitting complete graphics, just export a baseline SVG of the layout plus some overlay SVGs or even the JSONified data for creating the part highlighting via JS within the browser directly.
I personally preferred my PDF solution though because in that specific situation I wanted printed pages in front of me for assembly.
hi @pwuertz
I just tried your script with the nightly kicad and got the dreaded gettattr error on line 69. Would this be difficult to fix for the latest builds?