Skip to content

Instantly share code, notes, and snippets.

@adripo
Last active August 29, 2025 23:01
Show Gist options
  • Select an option

  • Save adripo/4d0df406ea86de9d1a52f09dab318538 to your computer and use it in GitHub Desktop.

Select an option

Save adripo/4d0df406ea86de9d1a52f09dab318538 to your computer and use it in GitHub Desktop.

Revisions

  1. adripo revised this gist Jul 25, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions change_filament_without_ams.gcode
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ;===== Change filament G-code without AMS ===
    ;===== version: 1.1 =========================
    ;===== original version date: 20230417 ======
    ;===== version: 1.2 =========================
    ;===== original version date: 20230719 ======

    ;===== description ==========================
    ; Everything between M620 and M621 is executed only if AMS is connected.
  2. adripo revised this gist Jul 19, 2023. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion change_filament_without_ams.gcode
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    NEW NO AMS
    ;===== Change filament G-code without AMS ===
    ;===== version: 1.1 =========================
    ;===== original version date: 20230417 ======
  3. adripo revised this gist Jul 19, 2023. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion change_filament_without_ams.gcode
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    NEW NO AMS
    ;===== Change filament G-code without AMS ===
    ;===== version: 1.1 =========================
    ;===== original version date: 20230417 ======
    @@ -6,8 +7,10 @@
    ; Everything between M620 and M621 is executed only if AMS is connected.
    ; All M620, M620.x and M621 commands are removed to enable manual filament change.

    ; first filament change is skipped
    {if toolchange_count > 1}
    M204 S9000
    {if toolchange_count > 1 && (z_hop_types[current_extruder] == 0 || z_hop_types[current_extruder] == 3)}
    {if z_hop_types[current_extruder] == 0 || z_hop_types[current_extruder] == 3}
    G17
    G2 Z{z_after_toolchange + 0.4} I0.86 J0.86 P1 F10000 ; spiral lift a little from second lift
    {endif}
    @@ -160,6 +163,7 @@ M204 S[default_acceleration]
    {else}
    G1 X[x_after_toolchange] Y[y_after_toolchange] Z[z_after_toolchange] F12000
    {endif}
    {endif}
    ;===== AMS commands skip ====================
    ; Since there is no AMS, the following three lines are used solely to suppress
  4. adripo created this gist Jul 18, 2023.
    171 changes: 171 additions & 0 deletions change_filament_without_ams.gcode
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,171 @@
    ;===== Change filament G-code without AMS ===
    ;===== version: 1.1 =========================
    ;===== original version date: 20230417 ======

    ;===== description ==========================
    ; Everything between M620 and M621 is executed only if AMS is connected.
    ; All M620, M620.x and M621 commands are removed to enable manual filament change.

    M204 S9000
    {if toolchange_count > 1 && (z_hop_types[current_extruder] == 0 || z_hop_types[current_extruder] == 3)}
    G17
    G2 Z{z_after_toolchange + 0.4} I0.86 J0.86 P1 F10000 ; spiral lift a little from second lift
    {endif}
    G1 Z{max_layer_z + 3.0} F1200

    G1 X70 F21000
    G1 Y245
    G1 Y265 F3000
    M400
    M106 P1 S0
    M106 P2 S0
    {if old_filament_temp > 142 && next_extruder < 255}
    M104 S[old_filament_temp]
    {endif}
    G1 X90 F3000
    G1 Y255 F4000
    G1 X100 F5000
    G1 X120 F15000
    G1 X20 Y50 F21000
    G1 Y-3
    ;===== custom filament change ===============
    ; cut filament
    G1 X5 F300
    G1 X20 F12000
    ; move to poop chute
    G1 X70 F12000
    G1 Y245
    G1 Y265 F3000
    ; push a little filament out and then retract out
    G1 E10 F200
    G1 E-10 F200
    G1 E-20 F500
    ; pause for user to load and press resume
    M400 U1
    ;===== continue =============================
    {if next_extruder < 255}
    M400
    G92 E0
    {if flush_length_1 > 1}
    ; FLUSH_START
    ; always use highest temperature to flush
    M400
    M109 S[nozzle_temperature_range_high]
    {if flush_length_1 > 23.7}
    G1 E23.7 F{old_filament_e_feedrate} ; do not need pulsatile flushing for start part
    G1 E{(flush_length_1 - 23.7) * 0.02} F50
    G1 E{(flush_length_1 - 23.7) * 0.23} F{old_filament_e_feedrate}
    G1 E{(flush_length_1 - 23.7) * 0.02} F50
    G1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}
    G1 E{(flush_length_1 - 23.7) * 0.02} F50
    G1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}
    G1 E{(flush_length_1 - 23.7) * 0.02} F50
    G1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}
    {else}
    G1 E{flush_length_1} F{old_filament_e_feedrate}
    {endif}
    ; FLUSH_END
    G1 E-[old_retract_length_toolchange] F1800
    G1 E[old_retract_length_toolchange] F300
    {endif}

    {if flush_length_2 > 1}
    ; FLUSH_START
    G1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_2 * 0.02} F50
    G1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_2 * 0.02} F50
    G1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_2 * 0.02} F50
    G1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_2 * 0.02} F50
    G1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_2 * 0.02} F50
    ; FLUSH_END
    G1 E-[new_retract_length_toolchange] F1800
    G1 E[new_retract_length_toolchange] F300
    {endif}

    {if flush_length_3 > 1}
    ; FLUSH_START
    G1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_3 * 0.02} F50
    G1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_3 * 0.02} F50
    G1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_3 * 0.02} F50
    G1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_3 * 0.02} F50
    G1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_3 * 0.02} F50
    ; FLUSH_END
    G1 E-[new_retract_length_toolchange] F1800
    G1 E[new_retract_length_toolchange] F300
    {endif}

    {if flush_length_4 > 1}
    ; FLUSH_START
    G1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_4 * 0.02} F50
    G1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_4 * 0.02} F50
    G1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_4 * 0.02} F50
    G1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_4 * 0.02} F50
    G1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}
    G1 E{flush_length_4 * 0.02} F50
    ; FLUSH_END
    {endif}
    ; FLUSH_START
    M400
    M109 S[new_filament_temp]
    G1 E2 F{new_filament_e_feedrate} ;Compensate for filament spillage during waiting temperature
    ; FLUSH_END
    M400
    G92 E0
    G1 E-[new_retract_length_toolchange] F1800
    M106 P1 S255
    M400 S3
    G1 X80 F15000
    G1 X60 F15000
    G1 X80 F15000
    G1 X60 F15000; shake to put down garbage

    G1 X70 F5000
    G1 X90 F3000
    G1 Y255 F4000
    G1 X100 F5000
    G1 Y265 F5000
    G1 X70 F10000
    G1 X100 F5000
    G1 X70 F10000
    G1 X100 F5000
    G1 X165 F15000; wipe and shake
    G1 Y256 ; move Y to aside, prevent collision
    M400
    G1 Z{max_layer_z + 3.0} F3000
    {if layer_z <= (initial_layer_print_height + 0.001)}
    M204 S[initial_layer_acceleration]
    {else}
    M204 S[default_acceleration]
    {endif}
    {else}
    G1 X[x_after_toolchange] Y[y_after_toolchange] Z[z_after_toolchange] F12000
    {endif}
    ;===== AMS commands skip ====================
    ; Since there is no AMS, the following three lines are used solely to suppress
    ; the T[next_extruder] command.
    ; If these lines were omitted, the T[next_extruder] command would be executed
    ; after this code, leading to system hang as the toolchange command wait for the AMS.
    M620 S[next_extruder]A
    T[next_extruder]
    M621 S[next_extruder]A