Hi,
I have written recently a small plugin which at some point modifies (deletes) graphical items from a Fab layers based on DNP status. It works as indented, however now I need to write a plugin which will revert that modification.
I know that I can simply select all of the modified components and use “Update footprint from the library” tool, but it requires me to manually select those and it will become irritating in the bigger projects.
Is there any way of triggering “update footprint from the library” using a function from pcbnew?
Below I am adding a pseudocode of the plugin code I had in mind:
class PluginName(pcbnew.ActionPlugin):
def defaults(self):
.
. Not important right now
.
def Run(self):
board = pcbnew.GetBoard()
footprints = board.GetFootprints()
for footprint in footprints:
if footprint.IsDNP():
#Disregard all changes made locally by updating the footprint from the library
footprint.UpdateFromTheLibrary()
.
. Do further stuff
.
pcbnew.Refresh()
Hi,
Thanks for suggestion. I have checked the out IPC API (by which I mean configuring everything, running example files, reading through existing documentation and trying to modify existing plugins). Sadly I havent found any tools that could be useful for my task. I know the documentation is still under development, so maybe I will just have to be patient.
However that got me thinking - if “Update footprint from library” tool is implemented in KiCAD then there must be a way for me to check out how does it work, right? Do you know if this tool is just another plugin or if it built into KiCAD itself? And what is the best way to see how exactly does it work?
Becasue if it is another plugin, then maybe I would be able to use it in my script?
In addition, I would like to stay with SWIG for this project. I know it will be deleted with the next version of KiCAD, but I am afraid that my current coding skills are far subpar, for me to try using API that is still under development. I imagine that porting the script from SWIG to IPC API will be easier for me.
There are also many features missing and the devs are open to suggestions on what to add to the API
You’ll find this somewhere in the KiCad codebase. I can’t tell you where though.
Understandable, I struggle with the API as well and the devs have no time answering my questions. I spent hours already getting a basic structure working and I still don’t understand most things. I already posted a few questions here on the forum regarding the API and never got any response.