TL;DR; Provide an option to align components to grid (based on grid origin) in layout, similar to what was offered by the “pcb-action-tools” plugin.
I know there have been multiple topics on this, but I’ll try again to highlight the issue:
When you import any new components from schematics to layout, the positions of all new components are almost always off grid. This means that it’s very difficult to easily align anything to a board edge or to align components neatly against eachother if using a metric grid (The assigned positions of new components don’t seem to match up with an imperial grid either).
There are some workarounds, such as manually set the the position of each component on grid and/or using the Align-Distribute tools. Sadly, these workarounds are a little finicky and strange.
The plugin “pcb-action-tools” does provide this necessary functionality, but it’s sadly not yet been officially updated to Kicad 8 in the Plugin Manager and I’m not skilled enough in software development to manually compile and install it.
I am not sure whether this is very useful. When you start a PCB, you have to sort all footprints and place them individually anyway. It does not take much extra to line them up during placement if you find this important.
When looking at it from the other side. It does look like a logical function to have in KiCad. It’s possible there is already a feature request for this on gitlab, or it may be worth creating one.
There are also other feature requests on gitlab that can help with this. There is a request to be able to add explicit snap points for footprints, this is for example useful for footprints which are “chainable” such as some screw terminals. I also read something about a request to be able to snap footprints together by their courtyard. This would also allow for making rows easily and with minimal spacing.
In my opinion, it does take quite a bit of extra time. Yes, you will have to individually place every component, but the action required to move them onto the grid is very cumbersome, since you need to go to the properties manager and manually truncate the position value.
My main workflow is aligning components visually by their courtyard, so having components start off grid really messes with this.
The suggestion of “snap components by courtyards” is wonderfully intriguing, though!
If you grab a footprint by it’s center, then the center is placed on grid after a move, if you grab a footprint by a pad, then the pad is placed on grid. I attempted to grab a footprint by the courtyard, but the courtyard does not have snap points, so the footprint gets selected by a pad instead.
Normally KiCad places the selected snap point of a moved footprint on the current grid. By using a combination of setting a suitable grid beforehand (not too fine, usually 5 to 10 grid points between the wished footprint pitch) and taking a bit care of which point of a footprint you snap to (don’t mix footprint centers and pads) I find it easy enough to align a row of footprints by just placing them on the grid and aligning them on the first placement. Making use of the hotkeys (just hover mouse over a footprint and press m to move, or d to drag while keeping tracks attached) also helps.
Update: I did find a workaround.
Apparently, you can force installation from file of an outdated plugin. I tried installing pcb-action-tools v1.0.6 from a downloaded zip-file, and it worked! The snap to grid works too.
Still it, would be nice to have the feature built into Kicad, so you don’t have to rely on community plugins for (seemingly, from my layman point of view) simple and very useful features.
I would say either edge of courtyard or center of courtyard. I’m not sure exactly how the DRC works with regards to exactly which part of the line it works with. I think it’s best to snap to the same things the DRC works with. I know that Eagle uses the edge of each line (line width does matter here) at least.
Sorry, my comment was unclear.
Say the board and footprints are not square; rectangles or odd shapes, with and without arcs.
To which section of the courtyard will you assign the anchor?
How will you determine which footprints need that alignment?
To which border of the board will that anchor be aligned?
It seems to me that a courtyard aligning system is no better than the current system. Kicad also has at least eight positioning tools, plus Grids, to make aligning footprints easy. Have you tried using them?
Why do you want to align footprints to a grid? I can understand symbol alignment, but what is the purpose of footprint alignment?
I have never noticed it. I was even sure that it is not true. So I have just checked it and you are right -they are really off grid!
I thought after 7 years using KiCad I know such things but I see KiCad still has many surprises for me
So footprints in some automagic way have to go back to grid that I never even noticed them being off grid.
My first step at PCB is to divide components into groups (hotkey P after selecting group at schematic). Then I position footprints in each group touching each other (with their courtyards) to take up as little space as possible. I think during that time they get to grid because when moved they are grabbed by their centers.
What ?
I have never done anything like that!
I think I very rarely sow properties manager. Need not to use it at all.
If you do it with each footprint than you have to be very patient.
I place components touching their courtyards. DRC in V4 and V5 had nothing against it, but later KiCad versions began to complain when courtyards were one on another so I switched this test off. It also began to complain on my pin1 markings in courtyard so I also switched this error messages off.
Before KiCad I was working with 5 mils grid so all my footprints had courtyard in 5 mils grid. Together with moving in 2017 to KiCad I decided to change my grid from 5 mils to 0.1mm. So, knowing that I like to place footprints touching with their courtyard rectangles I just decided that all my footprints have courtyard in 0.1mm grid and I have never used any other footprint. When I position footprint centers in 0.1mm grid their courtyards are also in grid.
I have noticed off grid problem at schematic when moving small block containing symbols and off grid texts that block was grabbed by its counted center and this center was positioned in grid so symbols landed off grid. But at PCB I have never noticed any off grid problem.
the solution mentioned by Piotr (define all footprints with a coherent grid and later place the footprints with this grid enabled) is working in principle
also snapping by courtyard is also, at least partly, implemented:
enable the “Snap to all layers” snapping mode
define a hot key for “Move with reference” and use this command to place the footprints
now select a FP, press the defined “Move with reference” hotkey, select the courtyard edge of that hotkey (snapping helps for this), move to courtyard edge of the neighboring footprint (snapping to that courtyard edge helps)
my personal hotkey definition:
M → standard move
CTRL+M → move exactly
SHIFT+M → move with reference
regarding the original topic: move selected footprints to grid: I find the current solution (use plugin for this task) good. It helps to not clutter the kicad GUI with seldom used functions, but provides a solution for users who want this function. It’s more important that kicad get’s a real stable API, so the plugin developers are not forced to change (bugfix) their plugin with every new kicad release.
I think you’re taking this a bit too seriously.
Aligning footprints is for visuals only, it does not affect the way a circuit works. It can help a bit with assembly, inspection and rework, but how do you align a resistor with a SOIC anyway?
But it’s a weird thing about PCB design. Even though I know it is a waste of time, I also have a difficult to resist urge to make nice looking rows of SMT resistors and capacitors.