Filament Change Gcode

Just found this nice Gcode to help you set up a filament change for multiple colors in a print at a certain layer. Quoted from the original site which is linked below.

How to pause printing to switch filament

Posted by carlos, 16 November 2015 3:47 pm

In order to do multi color print with one extruder. You can pause the printer at a specific height. Make sure your machine supports the M600 command otherwise just see what they use for said firmware. Just insert the following after the layer height call in the gcode file. For example search for “; layer 5” and add the following after it:

;Pause Code
G91 ;Set Relative Mode
G1 E-5.000000 F500 ;Retract 5mm
G1 Z15 F300 ;move Z up 15mm
G90 ;Set Absolute Mode
G1 X20 Y20 F9000 ;Move to hold position
G91 ;Set Relative Mode
G1 E-40 F500 ;Retract 40mm, this can be commented out if you just want to pause to insert magnets or something.
M300 ;Beep (marlin)
M600 X0 Y0 Z10 E10
G90 ;Set Absolute Mode
G1 F5000 ;Set speed limits, depending on slicer this can be set to your initial mm/min speed or it can be used for the following move only then the next layer will set the speed
G28 X0 Y0 ;Home X Y
M82 ;Set extruder to Absolute Mode
G92 E0 ;Set Extruder to 0

Running on smoothieware, make sure to have the following set up in your configuration file (from: http://smoothieware.org/switch):

## for switching filament
leave_heaters_on_suspend true
after_suspend_gcode G91_G0E-5_G0Z10_G90_G0X-50Y-50 # Gcode to run after suspend, retract then get head out of way
before_resume_gcode G91_G1E1_G90 # Gcode to run after temp is reached but before resume – do a prime

Please refer to for more information at https://reprap.org/wiki/G-code#M600:_Filament_change_pause

There is also the G4: Dwell command

Example: G4 P200

In this case sit still doing nothing for 200 milliseconds. During delays the state of the machine (for example the temperatures of its extruders) will still be preserved and controlled.

Lastly if you use simplify 3D check this forum post on how to do it from the slicer: https://forum.simplify3d.com/viewtopic.php?f=8&t=6725&p=29237