how to Change ublueprint's components in a plugin

  • Hello people who are reading my question.
    I have a c++ class, and a blueprint from it. I imagined defining the various components in c++ and then editing the blueprint manually in editor (I liked the visual editing feel). Then the blueprint always has a lot of idle or useless components, which means I don’t need to load them while the game is running.
    I designed a plugin (EditorToolbarButton) that I wanted to be able to click in the editor screen to automatically load the original blueprint in the directory I specified, then remove the components that were not needed, and then save the processed blueprint in a different path.
    Now the point is, I tried every function I could imagine and that I noticed in the official documentation, and it seemed impossible to change the components of the blueprint in the plugin code. However, when the blueprint of the editor screen was opened, there was an AddComponent button, which made me think that the plugin I had envisioned was possible. So this was my third day of thinking, and I was breaking down.