X-In/1-Out Non-Mixing Extruder - Automate SuperSlicer Filament Swaps

The following is basic documentation on how to setup SuperSlicer/Prusa Slicer/Slic3r to automatically change filaments though extruder stepper changes during a print.

I am not expert with Klipper, SuperSlicer, Prusa Slicer, and/or Slic3r. I will note any challenges that I’ve experienced during my setup and testing. I will also address any input provided in order to enhance this document for others to benefit from.

This builds upon the Config: X-In/1-Out Non-Mixing Extruder Config

Doc. Started: 08-dec-2022
Initial Completion: 09-dec-2022
Last Updated: 13-dec-2022

Klipper Version(s) this is working with:

SuperSlicer Version(s):


Printer is operational using the above noted Config and using Klipper’s [extruder_stepper] to provide additional stepper inputs to your hot-end.


  • Extruder - The complete system of a combination of a Hot End, one or more Extruder Stepper(s), and connection system (typically PTFE tubing) that drives and directs filament though the printer
  • Hot End - the device that melts the filament to be delivered to the print surface.
  • Extruder Stepper - The drive system that pushes the filament into the Hot End, typically comprised of an stepper motor, drive gears, and some type of containment system (typically PTFE tubing).

Hardware and Dimensions:

My printer is a Piper2 Core-XY using a Phaetus Dragon SF hot end and a 4-in/1-out SCP Splitter. Adjusting dimensions provided will be necessary and may reduce some issues related to my specific setup.

I’m currently using a dual-drive BMG extruder and a self designed 4:1 compact belt driven extruder. however the extruders as well as their location are not necessary for this document.

This is the gantry image of a Piper2 Core-XY. there are three areas to be aware of:

  1. Cool Zone - The area in the hot end that filament travels and should be ‘cool’.
  2. Cooling Tube Position - a dimension from tip of the hot end to about the middle of the Cool Zone. This position, in the Cool Zone, is used by the slicer to cool and shape the filament before removing during a filament swap.
    a) 45mm for E3D v6 (approx)
    b) 32mm for Dragon SF (approx)
    c) 36mm for Dragon HF (approx)
    d) 25mm for Mosquito (approx)
  3. Filament Park Position - a dimension from the tip of the hot end to where another filament can easily enter the filament path to hot end from another entry point. This will vary greatly from printer to printer. The slicer uses this dimension to remove one filament and load another. The shorter this distance, the less issues will be seen during printing.
    a) 140mm for my Piper2 Core-XY - Due to the length of this dimension, a Klipper error is induced and will be noted/address later in the document.

Klipper Configuration - printer.cfg options used:

The following additions are used during the filament change / Tool Change routine. Further explanation will be provided in the SuperSlicer Setup section.

[gcode_macro PARK]
description: Park the head to change tool
    M117 Parking Head...
    ##### set defaults #####
    {% set x = params.X|default(-15) %}      #edit to your park position
    {% set y = params.Y|default(0) %}      #edit to your park position
    {% set z = params.Z|default(10)|float %} #edit to your park position
    {% set e = params.E|default(4) %}        #edit to your retract length
    ##### save current x and y position ####
    SAVE_GCODE_STATE NAME=park_state
    ##### calculate save lift position #####
    {% set max_z = printer.toolhead.axis_maximum.z|float %}
    {% set act_z = printer.toolhead.position.z|float %}
    {% set lift_z = z|abs %}
    {% if act_z < (max_z - lift_z) %}
        {% set z_safe = lift_z %}
    {% else %}
        {% set z_safe = max_z - act_z %}
    {% endif %}
    ##### end of definitions #####
    {% if printer.extruder.can_extrude|lower == 'true' %}
      G1 E-{e} F2100
    {% else %}
      {action_respond_info("Extruder not hot enough")}
    {% endif %}
    {% if "xyz" in printer.toolhead.homed_axes %}    
      G1 Z{z_safe}
      G1 X{x} Y{y} F6000
    {% else %}
      {action_respond_info("Printer not homed")}
    {% endif %}
    M117 Head Parked...

PARK is used to move the print head off the purge block to a safe area for unloading and loading. This was done to remove heat from the printed objects.

[gcode_macro CONTINUE]
description: Continue's printing after tool change
    M117 Print Continuing...
    ##### set defaults #####
    {% set speed = params.SPEED|default(180) %} #edit to your travel speed in mm^2
    ##### end of definitions #####

CONTINUE (updated) - used to move the print head back to the purge block after loading filament. Will be adding the MOVE_SPEED option in the near future.

[gcode_macro FILAMENT_LOAD2]
description: Loads filament from splitter to hot end
gcode =
	M117 LOADING...
	G1 E110.0 F900
	G4 P900
	G1 E30.0 F150

FILAMENT_LOAD2 will extend the filament 140mm, from the Filament Park Position back to the Tip of the Hot End. This will be explained further and may not be needed if you have a shorter Filament Park Position dimension.

NOTE: I have a FILAMENT_LOAD1 gcode_macro that load filament from the stepper extruder gears to the Filament Park Position. It is not needed for the purpose of this document.

SuperSlicer Setup:

Printer Settings → General

  1. Set the number of Extruder Steppers configured in Klipper. This should be the total number of steppers in [extruder] and [extruder_stepper] objects. My printer has one extruder and one extruder_stepper = 2 extruders in SuperSlicer
  2. Check the Single Extruder Multi Material check box. This should enable additional features
  3. Confirm that the new menu object Single extruder MM setup is visible along with the number of extruder(s). If the new menu is not available, un-check the Single Extruder Multi Material, increase Extruders, an then re-check Single Extruder Multi Material. Once the new menu is visible, adjust Extruders to the correct number of your printer.

Printer Settings → Custom G-code

Add in the appropriate Tool change G-code. Mine is as follows:

;Tool Change g-code

During a filament swap, I decided to add some extra G-code that provides the following functions:

  1. PARK - Moves head off the printing area. This also removes hot end heat from the wipe tower during the loading process
  2. ACTIVATE_EXTRUDER EXTRUDER=[tool_name] - This does the physical switch between extruder_steppers in FW.
  3. FILAMENT_LOAD2 - loads the filament the needed 140mm from Filament Park Position to Tip. This may not be needed for shorter Filament Park Position dimensions.
  4. CONTINUE - Moves the print head back to the wipe tower so purging can take place.

General → Single extruder MM setup

Insert the value you determined from the first image above for Cooling tube position and Filament parking position. These values will be explained later on and how they work along with the Extra loading distance value.

General → Extruder (x)
These settings were explained in detail under my previous Confg post, link above.

Filament Settings
Reminder: Filament Settings are unique per filament selected. Make sure that you make changes to this section that is appropriate for each specific filament to be used.

Filament Settings → Multimaterial

This section is fairly long. Review and adjust as needed settings in the temperature, string reduction, and wipe tower settings.

Toolchange parameters…
These settings will be explained a bit more when we look at the generated g-code later in this document.

Adjust the Load and Unload speeds if you’d like. The image is more conservative than the defaults.

Change Number of cooling moves down to 1.

Pigment Percentage should be adjusted from 0 to 1 based on the filament pigment. 0 = natural/clear. 1 = black. This should be taken into consideration for how much purging is necessary to clean out the nozzle during the wipe tower moves. example: Light to Dark = less purging, Dark to Light = more purging needed.

Filament Settings → Custom G-code

Nothing out of the ordinary here. Great place to set PA values (based on filament selected and may be different for each extruder. I had to move the Z_ADJUST logic to the Printer Settings → Custom G-code → Start G-code so that the Z_ADJUST is not changed every time a tool is changed.

Print Settings
Reminder: Print Settings are unique per configuration selected. Make sure that you make changes to this section that is appropriate for each specific Printer Settings to be used.

Print Settings → Multiple extruders

Extruders, Ooze prevention, and Advanced sections will not be addressed in this document. Adjust as you see fit.

Wipe Tower needs to be Enabled and uncheck the Prime all printing extruders for starters. Feel free to adjust the default location of the Wipe tower position. It can be dynamically moved around on the 3D View before slicing. The remaining settings can be adjusted if/as needed.

Toolchange Workflow:

The following steps are a basic toolchange workflow in SuperSlicer.

  1. Ramming procedure - This is little positive extrustion moves and the print head moves back and fourth over the purge block to try to shape the end of the filament
  2. Retract to Cooling Tube Position - Four retraction sequence used to move and form the tip of the filament into the Cool Zone. Speed is controlled under Filament Settings and Unloading speed at the start value.
  3. Cooling Move - Configured by (Filament Settings) Number of Cooling Moves, Speed of Cooling Moves, and (Printer Settings) Cooling Tube Length. This too is done as the print head moves back and fourth over the purge block.
  4. Retract to Filament Park Position (140mm from Tip). Speed is controlled under Filament Settings and Unloading Speed value.
  5. Filament End G-code, if configured
  6. Tool Change G-code
  7. Filament Start G-code, if configured
  8. Tool Change Filament Load sequence - This is 3-step filament load process where the filament move the complete distance of the Filament Park Position dimension (140mm-ish) by 20%, then 70% and finally 10% of the total distance
    Distance = Filament Park Position + Extra Loading Distance configured in Printer Settings.
    Speed = Speed is controlled under Filament Settings and Loading speed at the start and Loading speed values.
  9. Purge (print) new filament on the wipe tower
  10. Continue printing part with new filament.

Example Sliced Model with Tool Change at Layer:

This image is of the sliced model. a simple logo with a color change at a layer. Purge/Wipe block is just to the top.

Generated G-code and explanation of settings:

Challenges & Issues:

Due to the long length of 140mm, this process, Klipper kept throwing a Move exceeds maximum extrusion (3.963mm^2 vs 0.640mm^2) error.
The G-code causing the issue is under the Tool Change Filament Load section:

Specifically the two X-moves in combination with the long E-moves.

To compensate, I decided to use SuperSlicer G-Code Substitution under Print Settings.

I needed three rules, one for each load distance, that would comment out the G-code. As long as I don’t change my Filament Park Position and Extra loading distance values, the configured regex will comment out any lines found in the created G-code.

G1 E27.6 F180
G1  X194.375  E96.6 F650
G1  X136.250  E13.8 F455

Find Regex 1: (G1\s*E27.6\sF[0-9]*) - Finds a G1(space)E27.6(space)F(any speed)
Find Regex 2: (G1\s*X[\0-9]*E96.6\sF[0-9]*) - Finds a G1(space)X(any value)E96.6(space)F(any speed)
Find Regex 3: (G1\s*X[\0-9]*E13.8\sF[0-9]*) - Finds a G1(space)X(any value)E13.8(space)F(any speed)

Corresponding Replace value can be anything. I added a semi-colon (comment character) followed by something so I would remember what was modified.

using at ${1} within the Replace with section will insert the original found text back into the saved g-code file.
; ${1} - G-code substitution since it causes Klipper Move exceeds maximum extrusion (3.963mm^2 vs 0.640mm^2)

Result G-code looks like:

; G1 E27.6 F180 - G-code substitution since it causes Klipper Move exceeds maximum extrusion 3.963mm^2 vs 0.640mm^2
; G1  X194.375  E96.6 F650 - G-code substitution since it causes Klipper Move exceeds maximum extrusion 3.963mm^2 vs 0.640mm^2
; G1  X136.250  E13.8 F455 - G-code substitution since it causes Klipper Move exceeds maximum extrusion 3.963mm^2 vs 0.640mm^2

Finally, to get the filament to load from Filament Park Position to Tip, I added in the FILAMENT_LOAD2 gcode_maco in the Tool change G-code section.

Printed Results:

To-Do Item(s):

I still need to adjust the Custom G-code in several areas by using {if wipe_tower == 1} logic to enable/disable mutli-color/single color print specific g-code.

I was unable to use the wipe_tower variable to key off of for g-code needed for non-toolchaning printing. I found a total_toolchanges variable was available and used that in my End G-code section in SuperSlicer to retract the filament at the end of a print:

{if total_toolchanges == 0}
; Unloads filament to Filament Park Position - 140mm from tip.  
; Only needed for non-multi-material prints.

Toolchanging printing routines have a built in final retract to Filament Park Position, so adding a similar final retract for non-toolchanging printing keeps the workflow consistent.

Filament Unload g-code_macro -
This was created to mimic the same process used during toolchanging printing. The retract to Cooling Tube Position, Cooling moves, and retract to Filament Park Position routine does not form a tail on the end of the filament.

[gcode_macro FILAMENT_UNLOAD]
description: Unloads filament from hot end to Filament Park Position
gcode =
#   Retract to Cooling Tube Position
    G1 E-15 F4800
    G1 E-13.65
    G1 E-3.9 F2400
    G1 E-1.95 F1440  ;-34.5mm retraction
#   Cooling Move 
    G1  E5 F1531
    G1  E-5 F2366
#   Retract to Filament Park Position
    G1 E-105.5 F2000  ;-140mm retraction total

This needs to be added to the klipper docs !


Outside of the Tool Change G-code and the issue I had with filament load, this document is more “slicer” than Klipper.

Bad part is, there isn’t even clear documentation on how to do filament swaps in the slicer documents either.

1 Like