Timelapse of the layout process

This was discussed recently at /t/time-lapse-routing-video/19749, but I do not think any obviously easy solutions were suggested.

I prepared a small script that prepares a timelapse for the project I am working on. It is a project that will be used for STEM outreach and education, so it was particularly important to have that type of materials.

Here is the final result:


The detailed description can be seen here https://blog.krastanov.org/2020/02/17/pcb-layout-timelapse/ and the code is here https://github.com/SpinWearables/SpinWheelHardware/blob/master/prettyvis.ipynb

The short version is that I used the python interface to set the plotter to produce SVG files and then used inkscape from within the script to clean up the SVGs. In my case I applied it to a completed project, working backwards and “faking” a timelapse, but you can also run the script periodically in the background and record your actual progress.

Feedback would be appreciated and I would be happy to expand upon the current functionality.


Nice, this gives an interesting plugin to generate presentations and tutorials. Could it be easily converted to a pcbnew action plugin?

One option at the end (if a dialogue allow some configurations) could it be: add the 3D rendered view at the end.

I have never tried to make a plugin for kicad, so I am not certain. Reading https://github.com/KiCad/kicad-source-mirror/blob/master/Documentation/development/pcbnew-plugins.md makes me believe it would be very easy. However, it would be helpful if someone can point me to an API documentation that says how to find the current file name and working directory of pcbnew from within the python plugin code.

import pcbnew
import os
board = pcbnew.GetBoard()
full_path_to_layout_file os.path.abspath(board.GetFileName()
import os
path_to_current_working_directory = os.getcwd()

You could also make the GUI with which one could control where the images are written and start, pause and stop recording. For ideas look into implementation of Length stats plugin

I did remember a good Pcbnew Action Script tutorial. But basically you have to load the dialog/code/python module though a __init__.py file and use the as use are already using in python.

The Interactive BOM plugin init file is good start point, it shows also how to register the icon to a button of your script.

To create so GUI interface, I have used wxFormBuilder (and the wx package).

Neat! I store my projects in git repos, it might be interesting to build a snapshot for every commit and put that into a timelapse

1 Like

Not sure if this helps, but from the FAQ:

@stefank, Nice video. I like it! Welcome to the forum. Thank you for posting hypertext links to your code and to your motivation on your blog. I think it would be an nice if you added an option of how long to wait, in seconds, between successive displays (frames) of the routing process you are documenting. For example, if the time now is 0.25 s, or 4 frames a second, it would be nice if you could vary the time between 0.25 s and 30 s. Additionally, I think it would also be nice to give the video ( a sequence of photographs played in rapid succession that gives the viewer an impression of motion) viewer a way to stop and replay the video in order to contemplate your layout method.

I program in C and C++. Your excellent example program and MitjaN’s post push me toward learning Python as well.

@hermit, Thank you for posting your FAQ URLs. I will look through them and maybe learn something I didn’t know.

1 Like

I tried to run but got a “Segmentation fault (core dumped)” at the first loop. Follow the script (copied by your @stefank).pcb2gif.py (5.5 KB)

Could someone reproduce this?

I have been using my version on occasion. Could you elaborate where you get the segfault (code line, etc)?

I am using last Nightly on Ubuntu 20 using Python3 (also the decrepit Nightly of Ubuntu 16.04 using Python2).
Follow the script version that I am using pcb2gif.py (5.6 KB)

Pcbnew file example Wavegen buffer.kicad_pcb (380.5 KB)

I am getting this segment fault at the first loop, doesn’t not matter the Pcbnew file that I use.

python3 pcb2gif.py 
Opening the PCB file...
Creating the intermediary output files...
Generating the track images (317 in total)...
Segmentation fault (core dumped)

The error happens on iteration number 159 in the first loop.

Maybe you are simply running out of RAM? (I have used the script only for rather simple boards, but for a large board one might need to do skip 9 out of 10 steps to make it reasonable) I will try your example pcb file later today.

Could it be but I doubt that is the computer limitation, maybe some Python memory limitation, since this work computer mine have large RAM and the load indicator doesn’t change during the script execution.

But yes, we could design a function with this all option and after add the “Pcbnew action plugin” capability for others users.

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