I am trying to get into scripting in kicad. I managed to run my script by typing:
exec(open("path/to/file.py").read()) in the “python scripting console”.
The problem with this is that this is a rather annoying task to have to do after every change I want to test. I was kinda hoping to be able to do this, either through a hotkey in kicad, or from a makefile, so I could run it from my text editor / IDE / programming environment (vim in my case).
I know you can turn the file into a plugin, but then, as far as I can tell, you still have to navigate to the plugins dropdown twice (to refresh and run the script), which is even more mouse movement.
I also thought about creating a python script that just monitors a dummy file to see if it has been toched, and then run my script, so that I could just start that script from kicad which keeps running and put a
touch "dummy filename" in my makefile. But then I found out that a blocking setup which is constantly checking a file just freezes kicad while it is running (there is probably some sort of event based system I could use, but I have no idea where to even start with that).
Alternatively, I know you can use the pcbnew python module to edit the pcb file directly, but then you would have to somehow reload that file in kicad. I found a hotkey labeled “Revert” in the settings, which I thought would do that, but just doesn’t do anything as far as I can tell.
So, I was wondering if someone here knows of a way to do this.