Programmatic Selection of Modules, Pads, Tracks?

Hi, we’re building an augmented reality debugging tool where the cross-probing behavior between schematic and layout is extended to physical PCB. In other words, selecting a component, traces, text, or pin in the EESchema causes the corresponding element in PCBNew to be selected. We want to extend that paradigm to show the corresponding element on your physical board to be highlighted as well in augmented reality. We also hoping to make the reverse work: pointing out an element on the physical printed circuit board will cause the corresponding elements to be selected in EESchema and PCBNew.

To be able to do this, we need a programmatic way of seeing what the user selects in EESchema/PCBNew and to send that to our external program. I see text update along the bottom of the windows in both programs when an element is seleted, but is there a way to get an event trigger with this information?

Also, for the reverse behavior, is there a way to programmatically select modules and have them highlight in the PCBNew window and the EESchema window? I have tried kicommand by @HiGreg (very cool plugin, check it out), but commands like “modules U1 matchreference setselect” don’t seem to cause elements in the canvas to show “selected” state.

Much thanks for any pointers!

Having the canvas show the current state, when that state is changed by python, has been problematic. It might work ok in newer releases and there have been attempts to fix it. Normally, my recommendation is to change canvas to legacy and back. This will show new elements, remove elements, and update visually the select status of elements. This is all within pcbnew only. Eescema doesn’t have python access yet, so there is no way I know of to get information on selected schematic elements. It’s possible that when an element is selected in the schematic, that it is reflected in the select status in pcbnew. Though there is not a way I know of to be notified of that when it happens. You may be able to run the kicommand “selected” to identify elements that are selected through cross probing from the schematic.

1 Like

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