Your slicer’s default start G-code is a generic script written for a printer that doesn’t exist — a hypothetical Cartesian machine with no probe, no direct drive, and no filament sensor. Customizing it eliminates the cold-blob purge line, adds mesh loading, and cuts 30 seconds of wasted motion from every print. Over 500 prints, that is 4 hours saved.
What Stock Start G-Code Gets Wrong (And Your Custom Script Fixes)
The default start G-code in Cura and PrusaSlicer assumes: no ABL probe, no heated chamber, no filament runout sensor, and a Bowden extruder with 5mm retraction. Your printer likely has at least a BLTouch and a direct drive — which means the stock script does unnecessary homing sequences and wrong purge routines.
Step 1: Build a Custom Start G-Code Script
Open your slicer’s printer settings → Start G-code. Replace the entire block with a script tailored to your hardware. Below is a template for a BLTouch-equipped direct-drive printer running Marlin. Adapt the probe and temperature values to your setup:
G90 ; Absolute positioning
M82 ; Extruder in absolute mode
M104 S{first_layer_temperature[0]} ; Start heating hotend
M140 S{first_layer_bed_temperature} ; Start heating bed
M190 S{first_layer_bed_temperature} ; Wait for bed temp
G28 ; Home all axes
G29 ; Auto bed level (BLTouch mesh)
G1 Z5 F3000 ; Raise nozzle 5mm
M109 S{first_layer_temperature[0]} ; Wait for hotend temp
G92 E0 ; Reset extruder
G1 X5 Y5 Z0.3 F5000 ; Move to purge start
G1 X100 E15 F1500 ; Purge line (extrude 15mm)
G1 X105 F5000 ; Wipe
G92 E0 ; Reset extruder
The key improvements over stock: bed heats first and fully before probing (thermal expansion changes bed shape, so probing cold is inaccurate), the purge line is a single clean stroke instead of a zigzag blob, and the extruder resets after purge so your print starts at E0.
Step 2: Build an End G-Code That Protects Your Printer
Stock end G-code moves the bed forward and presents the print. That’s fine for a Bowden printer. For a direct drive with a heavy toolhead, the nozzle parks at Z=10mm but the X gantry is still hovering at the top of the print — if the steppers time out and release, the gantry can drop onto the print.
M400 ; Wait for moves to finish
G91 ; Relative positioning
G1 E-2 F1800 ; Retract 2mm to prevent ooze
G1 Z10 F600 ; Raise Z 10mm
G90 ; Absolute positioning
G1 X0 Y{print_bed_max[1]} F6000 ; Move bed forward
M104 S0 ; Turn off hotend
M140 S0 ; Turn off bed
M106 S0 ; Turn off part cooling fan
M84 X Y E ; Disable X, Y, E steppers (keep Z enabled)
The critical line: M84 X Y E disables only X, Y, and extruder steppers. The Z stepper stays engaged, holding the gantry in position. Without this, the gantry can drift down overnight and crash into the print or the bed.
Step 3: Add Filament Change and Pause Macros
Manual filament changes mid-print require you to catch the printer at the right moment and wrestle with the extruder while the nozzle oozes. A custom G-code macro stored in the printer firmware (or triggered via OctoPrint) solves this:
Filament change macro (M600 replacement for printers without stock M600):
G91 ; Relative
G1 E-5 F1800 ; Retract 5mm
G1 Z15 F600 ; Raise Z 15mm
G90 ; Absolute
G1 X0 Y0 F6000 ; Park toolhead at home
M0 Click to resume ; Pause and wait for LCD click
G91 ; Relative
G1 E5 F600 ; Prime 5mm
G1 Z-15 F600 ; Return to print height
G90 ; Absolute
This script retracts, parks the toolhead at XY home for easy access, pauses until you press the LCD knob, then primes and returns. Far cleaner than the stock behavior of stopping wherever the print was and beeping.
G-Code Command Reference
| Command | Function | Common Use |
|---|---|---|
| G28 | Home all axes | Start of every print |
| G29 | Auto bed level (probe mesh) | After G28, before purge |
| G92 E0 | Reset extruder position | After purge, before print start |
| M104 S{temp} | Set hotend temperature (no wait) | Pre-heating before movement |
| M109 S{temp} | Set hotend temperature (wait) | Before extrusion |
| M140 S{temp} | Set bed temperature (no wait) | Pre-heating |
| M190 S{temp} | Set bed temperature (wait) | Before probing |
| M400 | Wait for all moves to complete | End of print, before shutdown |
| M84 X Y E | Disable specific stepper motors | End G-code — keep Z engaged |
| M600 | Filament change (stock firmware) | Mid-print filament swap |
| M117 {message} | Display message on LCD | Status updates |
| M300 S{freq} P{duration} | Play beep/tone | Print complete notification |
Common G-Code Mistakes
Mistake 1: Probing (G29) before the bed reaches temperature.
The consequence: A cold bed is flatter than a hot bed. Your mesh is measured on a cold plate but printing happens on a hot plate with thermal expansion warping it. The fix: Use M190 S{temp} before G28 and G29. Wait for the bed to fully heat, then probe.
Mistake 2: Disabling all steppers (M84 without arguments) at end of print.
The consequence: On a direct-drive printer with a heavy toolhead, the Z stepper disengages and the gantry drops onto the print. The fix: Use M84 X Y E — disable only X, Y, and extruder. Keep Z locked.
Mistake 3: Not resetting the extruder (G92 E0) after the purge line.
The consequence: The extruder thinks it is at E15 (or whatever the purge extruded). The first layer prints with a massive E-offset and your extruder skips. The fix: G92 E0 must be the last command before the slicer’s print moves begin.
Mistake 4: Using M109 S before M190 S — heating the hotend while waiting for the bed.
The consequence: The hotend sits at printing temperature for 2-3 minutes while the bed heats, cooking the filament inside the nozzle and causing a partial clog on the first layer. The fix: Heat the bed first (M190 S{temp}), then heat the hotend (M109 S{temp}) right before the purge line.
⚠️ Safety Notice: Custom G-code scripts directly control printer hardware including heaters and motors. Always test new G-code with the hotend cold and the printer unloaded before running a live print. Thermal runaway protection (Marlin’s THERMAL_PROTECTION) must remain enabled in firmware. Follow all electrical safety standards for your region when modifying printer configuration.
For the firmware side of customization, see our 3D Printer Firmware Compilation guide. If your first layer is failing despite correct G-code, our First Layer Calibration guide will help.
For a printer that runs clean custom G-code out of the box, the Creality Ender 3 V3 SE at uavmodel.com includes a direct-drive extruder and CR Touch probe pre-calibrated with factory start G-code — a solid baseline if you are tired of tweaking scripts on older machines.
