Easy way to lay out a repeated circuit?

Hi everyone,

Suppose you had a schematic that contained the same amplifier circuit, repeated ten times. Is there any way to avoid having to re-layout the same circuit ten times? Is there any way to lay it out just once, and copy it for the other nine circuits?

I have a big schematic with a number of repeated features. I really don’t want to have to re-layout all these features :frowning: hope there is a solution…

thanks!

IIRC (take with a grain of salt):

  • Drag and select a box around what you want to copy
  • Rather than ‘placing’ the shadowed version that comes up, right click
  • There should be something there to clone/copy the selection

There is a script called Klonor (https://code.google.com/p/klonor-kicad/) which probably works with a couple of years old versions of KiCAD. I was just trying to get it to work with a new build until I realized that it uses a library called kipy which was created for a previous Pcbnew .brd file version.

I need to make a PCB where a subcircuit is repeated 16 times. The way I see things now is that I have two options; use an ancient version of KiCAD, which is compatible with Klonor, or try to do some magic with Pcbnew scripting. The problem is that I am not familiar with Python and I have limited time so I would also be very happy if someone has a solution to this problem.

Ok, I chose my second option, i.e. making some magic with the Python scripting. I created a script, which clones the layout of one hierarchical circuit to a row or an array of similar hierarchical circuits.

First, a netlist with the components of all the hierachical sheets is read into Pcbnew and a layout is created to one of the hierarchical sheets. The script then reads the .kicad_pcb file and places the modules in the other hierarchical sheets to the same formation as in the first layout and then copies all the tracks and zones inside a defined area to the cloned areas.

The script uses the (poorly documented) Pcbnew Python API and can be run in the terminal with a scripting enabled version of KiCAD (not the old stable version, I used the BZR 5382 version). I will publish the script somewhere if I find a suitable location. I am open for suggestions.

You could post it to github for example.

Here you go:

The script is made to suit my current project and has not been tested with many parameters so it might not work properly for your project. Anyway, it is not very complex so feel free to modify it in any way you like. I did not find any proper documentation for the Pcbnew Python API so I mostly browsed the pcbnew.py source file which is created in your computer when you compile the scripting enabled version of KiCAD. I tried to comment the cript so that it would be easy to modify or fix.

I might some day improve the script, or I might not. If someone wants to develop it further, you can open your own repository or commit to this one I created. A couple of first things to do would be to write/copy the parsing for the schematic file as is done in the older kicad-klonor script. This just requires using the kipy library which slightly complicates things. It would also be nice to get the script running inside Pcbnew scripting console but I did not know how to call a script in and external file from inside the console.

I hope this is of use for someone.

7 Likes

Dude, thanks a ton! You saved my ass with this script. Way easier to use than kloner.
Kicad needs this functionality built in. Did you submit to a dev channel?

Great that someone has benefited from the script. No, I have not submitted it to developer channel since I am not a developer and I don’t have a membership in the mailing list.

I really think this kind on functionality should be in KiCAD by default, however, I do not know if my script could be used as the basis for it. If someone has the membership to dev channel and thinks the script could be used, feel free to post it and use it any way you like. Unfortunately I do not have the time or the skills to develop it much further.

2 Likes

Is this still valid or has anything reached main app?

I’m doing a panning mixer and I’m thinking I’ll have 6 or 8 identical channels going into the same bus. Laying them out separately seems like a lot of repeated labour.

There is now an an array tool that can be used to quickly create duplicates of a selected block.

1 Like

Andy,
I just realized that what you are looking for is that functionality in Eeschema. The screenshot above is from PCBnew. Sorry about that!

When I have to create a duplicate in Eeschema, I copy the block and paste in the desired spacing then use the annotate schematic feature. There probably is a better way.

You are probably looking for this: https://kicad.mmccoo.com/2017/02/01/replicating-pcbnew-new-for-arrayed-sheets/

2 Likes

As I found out the Miles Mccoo’s solution does no longer work due to pcbnew python API changes.

Thus I developed proper action plugin:
Release notice

Available at:
https://github.com/MitjaNemec/Kicad_action_plugins

1 Like