.GCODE
G-code for 3D printers
Introduction
G-code is the language of numerically controlled machines, standardised as RS-274 and used by CNC mills and lathes for decades. 3D printers use their own dialects of it. A slicer turns a model into a G-code file made for one printer: every move of the print head, every change of temperature and every length of filament to push.
Because the file is made for a particular printer, nozzle and material, it is the last step before printing and is rarely shared between different machines.
Software
- PrusaSlicer (Windows, macOS, Linux)
- UltiMaker Cura (Windows, macOS, Linux)
- Bambu Studio (Windows, macOS, Linux)
- OrcaSlicer (Windows, macOS, Linux)
- OctoPrint (printer host, runs on Linux and others)
- Klipper (printer firmware)
- Marlin (printer firmware)
Structure
A G-code file is plain text, one command per line. Each line starts with a command letter and number, followed by parameters, each a letter and a value. A semicolon starts a comment, which slicers use for settings, layer markers and print time estimates.
| Command | Meaning |
|---|---|
G0, G1 | Move to the given X, Y, Z, pushing E of filament, at feed rate F |
G28 | Move to the home position |
G90, G91 | Absolute or relative positions |
M82, M83 | Absolute or relative extrusion |
M104, M109 | Set the nozzle temperature, without or with waiting |
M140, M190 | Set the bed temperature, without or with waiting |
; layer 1
M140 S60 ; bed to 60 °C
M109 S210 ; nozzle to 210 °C and wait
G28 ; home all axes
G90 ; absolute positions
M82 ; absolute extrusion
G1 Z0.2 F3000
G1 X50 Y50 E2.5 F1500