Kicad board layout question

I wonder if the ideal KiCAD integration might be an option somewhere in the netlist importer (or just a menu option somewhere, since it’s rarely used) to take default positions from the schematic like that.

For subsheets - I suspect it doesn’t matter where exactly they get placed, once the subsheet components themselves are all grouped together-ish?

Really love this logical grouping - I spend so damn long reproducing something like this before I can really consider the physical layout, it’s a necessary, time wasting step, particularly for things like decoupling cap close to the correct pins etc. Nice work!

Right. I think for sub-sheets, all that’s needed is to make sure each sub-sheet (and the main sheet) have their components placed in non-overlapping regions. You’re going to move everything around right away anyway, so it doesn’t matter too much exactly where things are at that high-level, so long as there is some logical grouping (which you can control by how you lay components out in the schematic).

@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.

2 Likes

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 https://github.com/ian-ross/KiCad-parts/blob/placement-plugin/plugins/SchematicPositionsToLayout.py 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.)

3 Likes

@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: https://github.com/ian-ross/KiCad-parts/blob/placement-plugin/plugins/SchematicPositionsToLayout.py

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 https://github.com/ian-ross/kicad-plugins 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!

2 Likes

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