Custom g-code is something of a dark art amongst the slicer community. After using several slicers and comparing a variety of profiles, I realized a lot of the magic was happening in the g-code. Many of the best profiles utilized hardware commands embedded in a little-understood part of the settings.
These notes are based on my experiences with the Prusa i3 Mk3 printer. If you are using a different printer, please verify the hardware details are same. These pages may be a bit rough as I revise them and add new material. Please check back regularly for updates.
Until recently, tuning accleration and jerk settings required tweaking and inserting gcode commands by hand. More recent versions of slicers – notably Slic3r Prusa Edition and Ultimaker Cura – have begun exposing these settings in the printer, print and filament profiles, making them much more accessible and easy to adjust between prints. While moving these commands to the slicer GUI is a big improvement, there are still several things you’re likely to want to do at the start and finish of each print. Custom G-code is the right place to insert these functions.
Every now and then, you’ll run into a challenge that can’t be handled with your slicer settings. There may be printer options you want to enable, or setup procedures you want to run before, during or after a print. Most consumer-grade 3D printers are controlled using gcode, a rudimentary language used to instruct the printer to move, extrude or otherwise create a printed part. Fortunately, most slicers allow inserting custom g-code at several points during a print to work-around some slicer software limitatins.
- At the start of a print, startup gcode can insert printer initialization commands, warmup routines and nozzle priming.
- At the end of a print, end g-code is responsible for turning off heaters, motors and fans, but can also be tweaked to move the extruder and bed after a print.
- Between layer changes, gcode is useful for adjusting hardware settings like nozzle temperatures and other settings based on the current layer number or height.
While moving these commands to the slicer GUI is a big improvement, there are still several things you’re likely to want to do at the start and finish of each print. Custom G-code is the right place to insert these functions.
Please be sure that you’ve calibrated your printer, and particularly your Live-Z settings before using any of the following examples. These routines move the nozzle around close to the bed, and could cause damage if your printer is not adjusted properly.
Contact and feedback
Last updated on Apr 17, 2019