Grid.Space
Search…
GCode Macros
Variable Substitutions and Expressions in GCode Macros
current set of variable substitutions
All Modes "pre" and "post" (header/footer)
  • {top} = offset in mm of bed top Y axis
  • {left} = offset in mm of bed left X axis
  • {right} = offset in mm of bed right X axis
  • {bottom} = offset in mm of bed bottom Y axis
All Modes "post" (footer)
  • {time} = job run time (printing/milling) in seconds (fractional)
  • {print-time} = alias for {time} ... deprecated after 2.8
  • {print_time} = alias for {time} ... 2.9 and beyond
3D printing / FDM mode only
"feature" macro only (as of 3.4)
  • {feature} = feature region of the print (brims, infill, etc)
"pre", "post", and other macros
  • {temp} = hot end temperature
  • {bed_temp} = bed temperature
  • {fan_speed} = active cooling fan speed (usually 0-255)
  • {material} = length in mm of material (filament) used
  • {layers} = total # of layers
  • {layer} = current layer number
  • {height} = current layer height in mm
  • {range(from,to)} = evaluated using {layer} and {layers}
  • {progress} = 0-100% state of print output
  • {tool} | {nozzle} = current tool in use
  • {tool_count} = number of tools used in print
  • {tool_used_n} = whether tool # n is used in print
  • {z_max} = max build height in mm
  • {z} = current z position
  • {e} = amount of filament extruded
Anything inside {} will be evaluated using full expressions including use of Javascript's internal classes and methods. Example: {Math.min(layer/layers, 0.5) + 1}
Logical Code Flow (IF / ELIF / ELSE / END)
1
;; IF { layer >= 10 && layer <= 20 }
2
;; ..... inside 10-20 layer={layer}
3
;; ELIF { layer >= 15 && layer <= 25 }
4
;; ..... inside 15-25 layer={layer}
5
;; ELSE
6
;; ..... did not match previous tests layer={layer}
7
;; END
Copied!
PREAMBLE control (v3.4+) allows for intro comment and config list to be re-positioned after the header or disabled. This was introduced to allow GCode output to work with Ultimaker.
;; PREAMBLE OFF
;; PREAMBLE END
CAM Mode
  • {tool} = CAM tool #
  • {tool_name} = CAM tool name
  • {time} = dwell time in seconds
  • {time_ms} = dwell time in milliseconds
  • {time_sec} = dwell time in seconds
  • {speed} = spindle speed
  • {spindle}, {rpm} = spindle speed (v2.7+)
simple algebraic expressions supported in the form
  • {token+n} {token-n}
Copy link