March 12, 2026
Description
Rather than setting layer temperatures manually for a temp tower, just include one line of G-custom code in PrusaSlicer's “before layer change G-code" section to do it automatically. You can use the attached .3mf file as a starting point for PLA, ABS, and PETG. Or manually import an .stl file and modify the G-code per the guide below.
Todo: use Prusaslicer v2.9.4 to automatically add debossed identification text to the model rather than use preconfigured .stls.
;Dockguy's temp tower layer height generator for PrusaSlicer
;
;Add the following to the Prusaslicer setting "Before layer change G-code" on the advanced printer settings tab:
;
;M109 S{d - (a * int((layer_z - b) / c))}
;
;where
; a == temperature step down per level (°C)
; b == thickness of bottom platform before the temp tower (mm) (1mm in example stl)
; c == thickness of each temp tower level (mm) (6.8mm in example .stl)
; d == maximum temperature to print (°C)
;
;
;Example for PLA course tuning 220->180°C:
M109 S{220-(5*int((layer_z-1)/6.8))}
;
;Example for PLA fine tuning where 210 was the best, test 218->202 in 2° steps:
M109 S{218-(2*int((layer_z-1)/6.8))}
;
;
;Example for PETG course tuning 260->220°C:
M109 S{260-(5*int((layer_z-1)/6.8))}
;
;Example for PETG fine tuning where 230 was the best, test 238->222 in 2° steps:
M109 S{238-(2*int((layer_z-1)/6.8))}
;
;
;Example for ABS/ASA course tuning 260->230°C:
M109 S{260-(5*int((layer_z-1)/6.8))}
;
;Example for ABS/ASA fine tuning where 240 was the best, test 248->232 in 2° steps:
M109 S{248-(2*int((layer_z-1)/6.8))}
;
;
;
;M104 vs M109
;
; M109 can have negative side effects on consistency since there may be a short pause before each layer. If you notice this, you can use M104 instead.
;
;G-code block that accounts for multiple filament types:
;
{if filament_type[0]=~/.*PLA.*/} M109 S{220-(5*int((layer_z -1)/6.8))}
{elsif filament_type[0]=~/.*PETG.*/} M109 S{260-(5*int((layer_z-1)/6.8))}
{elsif filament_type[0]=~/.*ABS.*/} M109 S{260-(5*int((layer_z-1)/6.8))}
{else} M109 S{250-(5*int((layer_z-1)/6.8))}
{endif}License:
Creative Commons — Attribution — Noncommercial — Share Alike
7