Kicad board layout question

@jensa This looks great! So far I have tended to manually cross-highlight the schematic to group circuits for layout.

This is a great starting point which should speed things up. Out of curiosity, what happens if you use it on a hierarchical sheet?

It doesn’t work for hierarchical sheets yet, as far as I can tell. I’m going to try to do something for that tomorrow.


I made a few changes to Jens’s script to make it work as a KiCad plugin and to make it work with hierarchical sheets. If you take the script from and copy it into your ~/.kicad_plugins directory, you should be able to use it as an entry in the “Tools -> External Plugins…” menu item in pcbnew.

The plugin just rearranges all the components in the layout to match the way they’re arranged in the schematic without doing anything to the layout file. It happens as a normal editing action, so you can do it, take a look, and undo it if you don’t like what you see. If you do like what you see, you can save the layout and continue editing.

(The way that hierarchical sheets are handled is rough: each sheet is just laid out in order down the page, ensuring no overlaps. Given what this thing is intended to be used for – the very first organisation of components when you first import a new netlist – that seems like a reasonable way to go.)


@jensa I think it’s a fantastic idea, can’t believe the scornful response it got on the KiCad forum :frowning:

@ian thanks for taking it up a level, this is one plugin I will definitely install!

I don’t know why, but I went to have a look at the KiCad forum discussion about it. It made me sigh. Certainly doesn’t inspire me to join the forums there…

Unfortunately it does not show up for me in Tools->External Plugins. I copied the script text from the repo, saved it to a text file with ‘.py’ as its extension, and put it in my scripts folder. I know (I think) that I’ve put it in the right place because it’s in the same directory as HTMLBOMGenerator, which does appear in the External Plugins menu.

Does pressing “Refresh plugins” under the Tools menu make any difference? And what version of KiCad do you have? I’ve only tested it with 5.1.6, and I’ve only started using KiCad quite recently, so I’m not at all familiar with differences with earlier versions.

Refreshing doesn’t help, nor does quitting out and relaunching KiCad. I’m running 5.1.6 under MacOS right now; will give it a shot under Windows when I have a chance.

Huh. Weird. I don’t know why it wouldn’t be working. One other thing to say is that I’ve only tested it on Linux, but I would have expected plugins to work the same on different platforms, as long as you put the plugin script in the right directory. Let me just check that what I’ve put on GitHub is right…

Oh, dammit, I think I know what it is. The script is Python 3, and I remember hearing something the other day about KiCad being locked on Python 2 for Windows and MacOS until version 6.

Let me have a look at some other plugins and see how they deal with the Python 3 vs. Pyhon 2 issue. I’ll let you know when it’s fixed.

In the meantime, this thing only works on KiCad 5.1.6 on Linux. (On the summer solstice in a leap year…)

1 Like

Very slick fix, @jensa. I’ll give it a try soon!

Wow, awesome plugin! It drives me nuts finding all the bits and moving them around before I can start routing. Especially when there are 100 x 100 nF caps next to each other all connected to 5 different power domains!

@JuliaTruchsess I believe that I’ve got it working on Windows now. (At least, I’ve tested it in a Windows 10 VM and it works there.) It was this Python 3 (Linux) vs. Python 2 (Windows and MacOS) thing.

The modified version is here:

1 Like

Works now under MacOS High Sierra, thanks!

Great! Thanks for testing it!

Great work @ian! So much better than what I hacked together :smiley:
Good call on adding POS_SCALE. I thought about that, but it kind of worked for my design so I didn’t add it. It’s very much needed on other designs.

@devbisme have added it to his list of Kicad tools already and he asked if I could put it in a separate repository. Given that this is now pretty much all your work, I’d suggest that you could make a repository for it and I’ll delete it from mine? I can tell @devbisme that it’s the new location?

@jensa I’ve put my version of the plugin in a repository at and I’ve replied on the KiCad forum to say that I’m happy to maintain it. I put a brief note in the README saying “based on an idea by @jenschr”. I hope that’s OK!


Fine by me! Thanks for taking this a lot further @ian! Much smoother than my script! :stuck_out_tongue:

No problem. You had the original idea. I don’t think I would have thought of that!

I agree that there could be features to help here, but one solution - which I find has general advantages in the design process - is to adjust the process a bit and have more connected schematic/layout work rather than rigid separation.

I would usually start with placing the main components in the schematic and layout, creating the library parts and doing the schematic in priority order. So first, you separately place the large mechanical parts of a fixed position e.g. connectors. Then high-speed circuitry, clocks and power supply parts. Then other distinct and contained areas.

Of course the schematic work is still far ahead, and the layout is only really at the “floor-planning” stage, but approaching it with this gradual staggered approach I think helps the overall design a lot. I find as I’m going along this brings up other things earlier I should consider which are useful for the schematic and general design.