G-code is just text. If you understand the 30 most-used commands, you can debug failed prints, customize start/end behavior, optimize Multi-AMS waste, and migrate profiles between slicers. Here's the reference — every M-code Bambu Studio and Orca Slicer actually output, with real production snippets.

G-code Structure: Header, Body, Footer

A sliced G-code file has three regions. The header (first 100-300 lines) initializes the printer: home all axes, set temperatures, load filament, prime the nozzle. The body is thousands of G0/G1 moves that draw each layer. The footer parks the head, turns off heaters, and ejects (on AMS-equipped machines).

Comment lines starting with ; carry metadata. Bambu Studio embeds extensive metadata at the top of every file: filament weights per AMS slot, total time estimate, layer count, model name, sliced-at timestamp.

Movement Commands (G0–G3, G92)

These are universal across all FDM firmware:

G28 homes all axes. G29 runs auto-bed-level (skipped on Bambu, which uses M1006 instead). G90 sets absolute coordinates; G91 sets relative — Bambu output is always G90 mode.

Temperature Control (M104, M109, M140, M190)

Four commands handle all temperature operations:

Multi-material profiles use M104 S0 T1 (set tool 1's hotend off) when switching to tool 0. Bambu AMS doesn't have multiple hotends — it switches filament through the same hotend, so you'll see M109 R230 T0 (Wait for hotend to drop to 230, on extruder 0).

Fan Control (M106, M107)

Bambu A1 has one part fan + one chamber heater fan (P2). X1C and P1S add a side aux fan (P1). G-code respects the printer's actual fan layout — if your G-code has M106 P1 but the printer has no aux fan, the command is silently ignored.

Bambu-Specific M-codes

Bambu firmware extends G-code with proprietary commands. These won't work on non-Bambu printers:

Orca / Klipper / Voron M-codes

Orca Slicer generates Klipper-flavored G-code by default. Klipper extends with macros:

Anatomy of a Bambu G-code Header

Here's a typical Bambu A1 start sequence (truncated to essentials):

; HEADER_BLOCK_START ; ; date: 2026-05-13 14:23:55 ; total_layers: 187 ; total_filament_used: 8.42g (PLA Basic Cyan) ; estimated_time: 47m 12s ; sliced by: Bambu Studio v2.0.4 ; ; HEADER_BLOCK_END

Then comes the printer initialization:

G90 ; absolute coordinates M83 ; relative extruder mode G28 ; home all axes M104 S220 ; set hotend, don't wait M140 S60 ; set bed, don't wait M190 S60 ; wait for bed M109 S220 ; wait for hotend M1006 ; auto bed level M620 S0A ; load AMS filament from slot 0 G1 Z0.2 ; lower nozzle to first-layer height G1 X10 Y10 E5 F1500 ; prime line, extrude 5mm

Modifying Start G-code Safely

Bambu Studio: Printer Settings → Machine G-code → Machine start G-code. This block runs BEFORE the slicer-generated body. Three common customizations:

  1. Wait for chamber temperature (X1C/P1S with chamber heater): add M191 S40 ; wait for chamber 40°C after bed/hotend wait. Reduces ABS/ASA warping.
  2. Reduce nozzle wipe (saves filament): replace default G1 X10 Y10 E5 with G1 X10 Y10 E2.5. Most prints don't need full 5mm prime.
  3. Custom progress message (LCD display): add M117 Printing: catmask v2.3 after homing. Shows during print.

Never modify the slicer-generated G1 body of a sliced file. Body coordinates are calculated relative to homing. Editing one move shifts everything downstream and crashes the head into the bed.

Debugging Failed Prints from G-code Inspection

When a print fails halfway, the G-code can tell you what was happening:

G-code File Size Reference

From our production data across 105 catalog models:

Summary

Our 3D Models You Might Like

Clicker Keycap Bases – Standard, Shift, Tab & Keyc Clicker Keycap Bases – Standard, Shift, Tab & 🐰 Bugs Bunny – Urban Vibes "Basketball Street" | 🐰 Bugs Bunny – Urban Vibes "Basketball Stree Draco Malfoy Keycap Clicker - 3D Printable Wizard Draco Malfoy Keycap Clicker - 3D Printable Wi Isabelle Inspired Animal Crossing Artisan Keycap - Isabelle Inspired Animal Crossing Artisan Key

Browse All Models →

Ready to Start Printing?

Browse our collection of 3D printable models — from flexi toys to cat masks.

Visit Our Store →