Composite components/Sub assembly


In my design I have several I/O which for natural reasons are identical, except for which contact and MCU-pin the connect to, see attached image for an example.

Is there a way to create a composite component/sub assembly of the parts circled in red?



On the schemaitc side yes. Use hierarchical sheets for this. You can instantiate the same sheet multiple times. (Remember the name of the first one. For getting a second instance, place down another hierarchical sheet but point it at the same file.) Do not use global labels in such an application, only use hierarchical pins and local labels.
This project of mine makes heavy use of that feature

There is no way to have a sub assembly in pcb_new.


Ooh, didn’t think of pointing them to the same file. Thanks!


I haven’t used it yet, but there is a plugin script that would (should?) help in this case. According to the readme for the plugin one does need to start with the repeated subcircuits on hierarchical sheets. Check out the Replicate Layout plugin found here:

The question then becomes, what version (and until 5.1 what platform) is @PerMalmberg using…


I’m using 5.0 on Windows.

Once I get to the layout part, I’ll have a look at that plugin. Thanks for making me aware of it.


I also develop simpler python script for 4.0.1-stable for doing 10 channel boards. If someone here interesting in it, I can post it online too. It is more interactive under console. I may try Kicad_action_plugins sometime to see if I can just through away mine or keep!

The script I have automatically use hierarchical design to figure out all the channel base on the Cmts.User Zones draw on the original routed channel. Then user can select which channel to replicate the same routing.


In order to use action plugins on windows with 5.0 without compiling Kicad, you can download V5 with enabled action plugins which is available at (28-Jul-2018 17:34)


When you do, please report back any issues and/or missing features


@MitjaN, I look into your code and found that we have similar approach only difference are:

  • Your replicator is base on a single module reference, and limited on one hierarchy level to clone. It work for KiCad5.0. Have GUI and console.
  • Mine clone is base on user specified rectangular areas for clone, and using “multi-level” hierarchy from schematic to found all the possible target channels equivalent to selected areas and allows user to chose which to clone or clone all. It work since Kicad4.0, potential work with KiCad5 too. Only console interactive.

My project will not able to use your due to the one hierarchy level limitation. My code wasn’t make to share on public, so if some one interesting, I will find some “night” to work it out and publish it.


This would be a nice feature to add. I have a couple of questions though

  • How does the user in your case select which hierarchy is the one to clone?
  • The highest one of all selected modules?
  • How do you generate information for the user which hierarchy will be cloned? As sheets are encoded basically as timestamps it is difficult to generate any user meaningful data. Do you parse whole project including schematics and then bind sheet it and schematic page name?


Q1 & Q2:
The way that I allow user to select a group of items using a rectangular areas is the key for your question about the hierarchy. They can be in any hierarchy, or event non-relative hierarchy. So speaking in your code term, every component in the rectangular are pivot_moudle(s).

My script (namely pcbnew_clone) will try to figure out a set of “similar” group using the help of schematic hierarchy (like the way you did - timestamp/AR) - then present to the user number of groups it found in number (with a sheet names - not sure how did I do it - it been too long for me to remember). User enter a number or a set of numbers for which channel(s) to be cloned.
In KiCad 4.0.1, I think the only way to get AR/timestamp is partially read from schematic files (Potentially kicad .net file would work too). My design were >4k Nodes, so I was make sure the script run around O(n) or O(n*ln(n)) faction.

My concept is that, user/people/me work on the board layout don’t care much about hierarchy of the schematic instead want to minimize amount of work by recognize a set of repetitive works. So clone the whole hierarchy (with multilevel) may not be necessary.

Another minor point - This is why I love KiCad - simple but flexible way cooler than using bulky Mentor Graphic.


Actually - I’m thinking if KiCad5 or above allow script to control the selection on the GUI - What we have can be very use full for better group selection/submodule selection to do other native KiCad operations as well as with other python script…


I think I get that, but then the user really should not screw up and add to selection a module, that has no coresponding modules to replicate.

Do you have any error checking if the user selection is not ready to be replicated?

I am not sure what you mean by “selection”. But with builds supporting wxpython you can produce dialog windows of any shape and size (@mmccoo’s work) and even add icons to the Kicad toolbar (@devbisme’s work) .


I think the way I handle it was just report to user that I cannot find the equivalent and therefore ignore and continue on…


I don’t treat it as error, but a warning and continue as best as I can…


I’m talking about “native selection” from KiCad that allow user to do “native” operations on (move, rotate, etc… ). If script can access to this native “selection” from user mouse - then possible:

  • @mmccoo work don’t have to keep check and un-check and set of components, or set of nets when he run his scripts.
  • @devbisme work seem to tell me that script has access the “native” selection which his script can be know which set of pin to swap for example - (so is selection is what I mean)
  • Also if script allow to add, or remove selected items from the “native” KiCad selection set - then that is complete what I try to said earlier.


Yes you have the option to check which items are selected. I use this a lot in my plugins. But while you can select/deselect each item within the script I haven’t managed to show this selection to the user. But I’ve tried this a couple of months ago.


Thanks for the idea. I’ve updated my plugin to support complex hierarchies.


@MitjaN While I’m not yet ready to start with the layout of my board, I’m very interested in what is possible to do with your script. Any chance you could do a demo video showing it off and how it is used?


I do not plan to do any videos. There is an animation available on GitHub, which was updated today, but if you have any questions don’t hesitate to ask me.