How to run a python script after every line of gcode

What is the problem?

I would like to collect some data from a sensor using a python program after every z-change. How can I do that with Octoprint. It is something like Octolapse functionality but I need to connect some other sensor.

What did you already try to solve it?

I come across the following plugin that does execute a python program with custom Gcodes. However, I need to modify the gcode in that instance. So, I am looking for a simple plugin, like octolapse.

Have you tried running in safe mode?


Did running in safe mode solve the problem?


That's what writing your own plugin is really for. Plugins are written in Python, and there's a hook that can be called to modify the gcode as it is sent to the printer. It would be a little silly for a plugin to offer what OctoPrint offers :wink:

1 Like

I answered this question in Discord earlier today, not sure if that was you, but you can do this with Event Manger settings.

1 Like

Thanks for resolving this @jneilliii

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.