---
tag: m0166
title: Gradient Mix
brief: Set a Gradient Mix
author: thinkyhead

since: 2.0.0
requires: MIXING_EXTRUDER,GRADIENT_MIX
group: mixing

codes: [ M166 ]

notes: Requires `MIXING_EXTRUDER` and `GRADIENT_MIX`.

parameters:
  -
    tag: A
    optional: false
    description: Starting Z Height. (Use `Z` to set the Ending Z Height.)
    values:
      -
        tag: linear
        type: float
  -
    tag: Z
    optional: false
    description: Ending Z Height. (Use `A` to set the Starting Z Height.)
    values:
      -
        tag: linear
        type: float
  -
    tag: I
    optional: false
    description: Starting Virtual Tool. The Gradient begins with this tool-mix. Below the Starting Z Height the Starting Virtual Tool fully applies.
    values:
      -
        tag: index
        type: int
  -
    tag: J
    optional: false
    description: Ending Virtual Tool. The Gradient transitions to this tool-mix as Z approaches the Ending Z Height. Above the Ending Z Height the Ending Virtual Tool fully applies.
    values:
      -
        tag: index
        type: int
  -
    tag: S
    optional: true
    description: Enable / disable the gradient in manual mode. When using the tool index alias, tool-change commands determine whether or not the gradient is enabled.
    values:
      -
        tag: enable
        type: bool
  -
    tag: T
    optional: true
    description: A tool index to reassign to the gradient. If no index is given, cancel the tool assignment.
    values:
      -
        tag: index
        type: int

examples:
  -
    pre: Gradient for a tall vase
    post: In this example no tool index is assigned to the Gradient. So the Gradient is enabled using `M166 S1` and disabled with `M166 S0`.
    code: M166 A0 Z250 I0 J1 S1
  -
    pre: Gradient as a Virtual Tool
    post: In this example the Gradient has been given a tool alias of 3. So the Gradient is selected with `T3`, and all other `Tn` commands will select a static mix.
    code:
      - M166 A0 Z250 I0 J1 T3
      - T3
  -
    pre: To use the static mix stored in T0…
    code:
      - M166 T
      - T0

---

Use [`M166`](/docs/gcode/M166.html) to set a gradient that will be automatically updated as the Z position changes during a print. The gradient smoothly transitions from one virtual tool to another between the given starting and ending Z heights. Below the starting height the starting virtual tool fully applies, and above the ending height the ending virtual tool fully applies.
