In this tutorial made for Digital Futures we explain the process to make gcode from python in blender. Get the files here: https://github.com/luigipacheco/python-toolpathing