Hello,
I am developing a small plugin action for pcbnew; it’s working well but I have a question about how to restore the previous selection after the plugin exits.
For context, the plugin action uses Layer Alignment Targets to make it easier to quickly align many items simultaneously. With one Layer Alignment Target set to an “X” shape, and all others set to a “+” shape, and with the same number of components selected as there are targets, the closest footprint to the “X” target serves as the reference for the others. Running the action sets the position offset from the other targets by proximity, and sets the rotation to match.
It’s easier to see it in a before/after screenshot than it is to describe in words…
All that is working well, but in the case where the user hasn’t selected enough components, I show a dialog and exit, but the selection is lost. Does anyone know how to restore the set of selected items when a Python action ends?
I’ve tried using “SetSelected()” on the footprints after the Dialog, but it seems “footprint.SetSelected()” does nothing. I’ve also tried following it with “pcbnew.UpdateUserInterface()” and “pcbnew.Refresh()”, also with no result.
Here is the complete plugin if anyone wants to give it a try / have a look…
com_zambetti_PositionFootprintsWithTargets.zip (402.4 KB)