all the major factors not covered by the G-code are covered in the M-code. M-code describes miscellaneous code and comes with the overall G-code, but accounts for different parts of the CNC process. The M-code accounts for when to stop axes or the spindle, when to change direction of spinning e.g. from clockwise to anticlockwise, and when to use coolant.
The best combined CAD-CAM software packages can both design and prepare your 3D CAD model for production to produce G-code files.

