Does KiCad have a way to auto-relocate footprints based on relative positioning?

Suppose I use relative positioning to exactly position a set of footprints exactly how I want them.

Now, later in the board design process I realize that I need to move this entire set of objects - not by drag/drop, but say by using the Arrange options (align center, align top, etc).

The problem is that if I move one object, the other objects that were positioned relative to it do not move with it. It looks like setting the position relative with Shift+P is a one-time operation that does not actually “link” the position in any way.

A simple example:

  • I have a connector J1, a capacitor C1 and two resistors R1 and R2.
  • I position C1 relative to J1, and then I position R1 relative to C1, and R2 relative to R1.
  • Now, later in the board operation I realize that I need to line up J1 with J2 by doing “align top edges”. So I do so. But now, C1, R1 and R2 are in the wrong place.
  • I now have to manually repeat all of the steps to move C1, R1 and R2 back into the correct positions based on relative positioning.

What I’ve considered/tried:

  • Grouping. This doesn’t work because the group bounding box is not the same as J2’s bounding box. So J1 and J2 will not be lined up, but instead the entire group of J1, C1, R1 and R2 (and whatever bounding box that group ends up with) gets aligned with J2. If I “enter group” then it acts just as if the group doesn’t exist and independently moves J1.
  • Some kind of script. I haven’t yet dove into how KiCad does scripting, but I’m not against learning how to write an automation script and I am an experienced programmer - I just don’t really know where to start with this kind of thing. (In a “Best case” scenario I would be able to include some sort of config file that specifies the part references and the relative position to some other part, and then press a key and have all the parts move according to the script. I could see all sorts of other “cool” ways to use the script to automate positioning as well - I basically need to be able to find a footprint by reference, determine the bounds of the footprint relative to its anchor point, and then be able to move the footprint.)
  • Just group and use drag/drop. There’s just no way to do that precisely enough, especially if the goal is to exactly line up J1 and J2.

Does anyone have any advice that would help me optimize this workflow? Thanks!

You can select several footprint by Shift-clicking (and de-select, just in case) and then move them exactly.
Might get a bit annoying with many footprints to move.

Thanks for the tip, but I have way too many components on this board to be handling it manually like that.

I looked up how to interact with the IPC API, and I tried using the kicad-python library to write a simple script that will just move a footprint to a static position. I am able to read the position of objects, but trying to update the objects causes KiCad to segfault. I don’t know if this is a bug or something with my particular setup, but segfaults are pretty hard to diagnose for me.

Should I post a bug report? Or better put, where’s the best place to post about this?

In the meantime I might try the SWIG API, but since it’s deprecated I don’t want to invest a ton of time in learning how to work with it.

Using the IPC API should never segfault, it’s a bug, please report it.

My workflow for your J1,C1,R1,R2 example, which should be moved to some position/alignement with J2:

  • group J1,C1,R1,R2 together
  • select whole group
  • grab and move this whole group, using Pad1 of J1 as “grabbing point”
  • move to pad 1 of J2 (or a similar point), using the “snapping” feature of kicad
  • use “Move exactly” to move the group away from J2. You can write the desired x/y distances into the “move exactly” dialog.

You may also try the command “Position interactively”.