Quick script to just swap the locations of two components in Pcbnew.
Definitely something that would be cool to see built into the main application, because I find myself need this all the time. Anyway, be the change you want to see in the world, this is what I know how to do to fix the issue.
Select two components, press the toolbar icon, and the position/rotation of the objects will be swapped.
Two outstanding issues:
It won’t do layers/flips yet
The objects get deselected after the operation. This seems to be a weird KiCad behaviour, I guess the code would have to select them again afterwards
PRs welcome, I’m unlikely to come back to this until I need to use it again
That’s the most recent one, but honestly not the most common one.
Use-case number two:
This is much trickier, so I’m not going to easily be able to set up a demo. Lay out out a dense microcontroller fanout, you get 80% of the way done, and then you see a way to swap two of your output pins that still work within what those peripherals can do. You change the pins on the schematic, forward annotate to update your netlist on the PCB, but the resistors coming out of them are set in place already. Now they need to be swapped in location.
As I said, this isn’t a groundbreaking plugin, it’s just to implement a small quick feature that totally should be in the main package.
The trouble with such simple plugins is that it’s easy to get lost in them and forget which one does what. I would not even consider a plugin for the first example, but instead just roughly sort them in the right order and then use align / distribute to make a row of them (More likely: just put them on a suitable grid). Sure, it’s more mouse clicks, but it really is such a small part of a PCB design that it’s hardly worth automating. Unless, maybe when you daily have such projects.
For your second example, I would just swap the resistors themselves:
Move one resistor to outside of Edge.cuts.
Grab the other by a pad, and snap it to the end of the track where the other resistor was.
Do the same with the first resistor to put it on the location of the second.
I like such little helpers as user-addon (even if I don’t use all such addon-functions).
On the other hand I hope that not to much of these functions slip into the main-application. Typically they are useful only for for a minority of users (but for these users the function is really useful, such as in your case) or only for seldom used tasks but will clutter the user-interface for all. So experienced users have often a set of helper-scripts they use and like, but this is not necessary the same set as the next users wants/needs.