"Update footprint from the library" using external plugin

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()

Thanks in advance

You might want to take a look at the KiCad IPC API introduced in KiCad 9, it has many new features and I bet something like this is possible.

Here’s a thread on this topic: KiCad 9.0 Python API - #110 by Mineotopia

Here are the docs: kicad-python documentation
Here’s how to set up your dev environment: For Add-on Developers | Developer Documentation | KiCad

This PR on my addon currently tries to port in from the old SWIG binding to the new IPC API (it is still WIP though): Update to IPC Python API by TimGoll · Pull Request #17 · DIaLOGIKa-GmbH/kicad-coil-creator · GitHub

Official examples of the new API: examples · main · KiCad / KiCad Source Code / KiCad API Python Bindings · GitLab

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.