What is the best way to align components in Pcbnew?

Every time when I change or add some new components in the scheme editor, and I update the PCB, the new components are shown as a group, so I put them somewhere near the PCB and move them one by one.

The grid I use is 25 mils (or at least that is what I would like, although 20 is also fine). However, when I move components, they never get aligned to each other. When I want to have e.g. some resistors aligned, I move them and after the move there is mostly 5 or 10 mils difference and moving them doesn’t help.

The only solution I have, is to change the grid size, correct the component, move it, and move back to 25 mils again. However this is quite tedious work… Is there a better approach?

Thanks in advance.

1 Like

May we assume these are all the same footprint? Context would suggest that but I want to make sure.

Yes they are, sorry for forgetting mentioning it (actually my question is very generic, but in this case I have a lot of 0805 resistors, but I have the same problems with other components which have the same footprint).

I wonder if the fact the 805 is metric and you are using mils the things get prepositioned a little differently, like rounding errors. I know what you’re talking about but I generally just work with a really small grid on PCBnew so I can get things where I want them.

I’d never get text where I wanted it on that course of a grid. I just live with components being a few fractions of a millimeter off.

1 Like

Does that mean you layout them by ‘eye’ or you check the coordinate numbers at the bottom?

I use full screen cursor and go by eye. For my stuff, that’s good enough.

1 Like

That’s a good idea (full screen cursor), that would help me enough too.

Full screen cross hair cursor is my default :sunglasses:

1 Like

Maybe this happened because you had different grid when you started, placed some components, changed the grid - and/or the grid origin - and placed new components. After that the old components are on the old grid and the new ones can’t be aligned with the old ones without changing the grid.

You should use only one grid for all component positions if possible. Now you should move the old components to the new grid before continuing, otherwise it will get more and more complicated with each new component.

Unfortunately there’s no “move items to grid” action which would move all selected items to nearest grid points. But you can try Align/Distribute from the context menu. Select all the wanted footprints which can be aligned vertically or horizontally. Open the right mouse button menu on the one which is in the correct grid in the right place. Choose the wanted align action, either vertical or horizontal (the menu items are misleading; aligning happens using the item on which the menu was opened and left/right or top/bottom work the same).


Thanks a lot for that answer.

And yes, I’m almost sure that happened (changing grid distance). What I did was place them using one grid distance. But when I want to optimize I changed them using a smaller grid size, and I’m almost sure in some cases I did not put them back.

I searched for the alignment menu, but couldn’t find it initially, but it depends what is selected. I think when I searched I accidentally also selected a via, text or trace, and in those cases (or some combination) the context menu is not shown… I tried it and it works great, although it can be tricky sometimes to select the components to be aligned, without selecting any other.

Also the ‘distribute evenly’ is a great option.

1 Like

You can select one by one with Shift+click. If you use group selection box you can try first unselecting Tracks and Through Via in Layers Manager -> Items.

1 Like

I know about the shift + click, also ctrl + click can help, but selecting via layers is really useful indeed; going to try that next time I need to align components.

Mine too now; useful option.

You probably already know this, but I didn’t when I started using KiCAD: when you are moving a component and snapping it to the grid, the point which snaps is not the footprint’s origin, it’s the point you selected when you selected the component. You can snap the center of a pad, or the corner of the courtyard, or many other points in the footprint, depending on what you want to accomplish.

When I was struggling with this I would have enjoyed having a ‘snap to footprint origin’ mode so it wouldn’t matter where I clicked to select the component…


I also found this out, but even then I tried several (or more) times to find the ‘correct’ snapping point, without much effect. Also, even if it seems close, it is not good enough always, so I use either the alignment option from now on, or I keep in mind to restore the grid setting after doing an optimalization.

That’s wrong. If you have one footprint selected the snapping point when starting moving it is the anchor point of the footprint. But if you have several, it’s the point on which you clicked M or RMB - which is awfully wrong in most situations.

Please vote here: https://bugs.launchpad.net/kicad/+bug/1830166

1 Like

Put the cursor on any pad on a footprint and press m, the footprint is attached to the cursor at the pad centre.

Application: KiCad
Version: 5.1.4-e60b266~84~ubuntu19.04.1, release build
wxWidgets 3.0.4
libcurl/7.64.0 OpenSSL/1.1.1b zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh/0.8.6/openssl/zlib nghttp2/1.36.0 librtmp/2.3
Platform: Linux 5.0.0-23-generic x86_64, 64 bit, Little endian, wxGTK
Build Info:
wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
Boost: 1.67.0
OpenCASCADE Community Edition: 6.9.1
Curl: 7.64.0
Compiler: GCC 8.3.0 with C++ ABI 1013

Build settings:

I forgot one thing for refining selection. Context menu -> Select -> Filter Selection. Selection filtering will probably be radically changed for 6.0, but the current system is handy enough.

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