We are looking for a way to execute custom gcode scripts.
We made a custom gcode script and put it in the gcode folder next to beforePrintResumed and so on.
We can execute the script from a button in the custom control editor.
Is it possible to execute the script in any other way like the action command plugin, or a gcode command?
Who's this "we"? Do you have a mouse in your pocket?
Move your script to ~/scripts. Adjust the path in your Gcode System Command to /home/pi/scripts/myscript, for example. Adjust the rights of the file with something like sudo chmod a+x ~/scripts/myscript to make sure it can run. Make sure that paths inside the script have full paths instead of assuming that anything is in the path or that you're in a certain directory.
You'll end up with something like OCTO900 which runs your script. You want to make sure that nothing in the script is blocking. If so, append an ampersand at the end of that line so that it runs in the background.
I do something similar and then I add OCTO805, for example, in my Gcode scripts to alert me that the print job is done (playing a sound event which is R2D2's whistle).
I guess the better way of asking the question would be, "how do I hook into the gcode stream and do something (call a script) specifically when certain gcode commands are seen?"
Take a look at this single-file plugin which foosel created. It hooks into the gcode stream and does something specific when it detects a particular style of temperature-related response from the printer. You might modify this approach for your own needs. She is describing what to do with it here.
There's also a recent plugin that was added that will allow for replacing stuff in the gcode stream, but I don't think it supports scripting/parameter replacement.
@kantlivelong might know more about this since he recently has worked with the gcode scripting stuff.
Hooking into the gcode stream is done with the terminal response plugin. And as jneilliii stated, that will let me sent individual lines of gcode or execute a shell script.
Where I would like to execute a gcode script or a gcode snippet.
I was thinking that if a gcode line came through the stream that looked like
{{set_pid}}
then the line would not be sent to the printer, but the set_pid snippet would be executed