# Macros

**URL:** https://klipper.discourse.group/c/macros/8.md

[Latest](https://klipper.discourse.group/latest.md) · [Categories](https://klipper.discourse.group/categories.md)

---

## [About the Macros category](https://klipper.discourse.group/t/about-the-macros-category/14)

<div class="topic-metadata">

**Author:** [@koconnor](https://klipper.discourse.group/u/koconnor)\
**Replies:** 0

</div>

Written a useful Klipper macro? Share it here.

---

## [Eddy: compensate bed\_mesh with tap](https://klipper.discourse.group/t/eddy-compensate-bed-mesh-with-tap/26142)

<div class="topic-metadata">

**Author:** [@nefelim4ag](https://klipper.discourse.group/u/nefelim4ag)\
**Replies:** 2\
**Last updated:** [July 20, 2026, 11:21am UTC](https://klipper.discourse.group/t/eddy-compensate-bed-mesh-with-tap/26142 "2026-07-20T11:21:28Z")

</div>

This is a macro to use Eddy’s tap output as a reference point for the bed mesh. Bed mesh can be done with scan/rapid\_scan/default methods. There should be zero\_reference\_position in the config. The trick is, as bed\_me…

---

## [Smart Chamber Heater - Adaptive Predictive Chamber Heating Macro for Klipper](https://klipper.discourse.group/t/smart-chamber-heater-adaptive-predictive-chamber-heating-macro-for-klipper/26154)

<div class="topic-metadata">

**Author:** [@Nesquirt](https://klipper.discourse.group/u/Nesquirt)\
**Replies:** 0\
**Last updated:** [July 9, 2026, 9:30am UTC](https://klipper.discourse.group/t/smart-chamber-heater-adaptive-predictive-chamber-heating-macro-for-klipper/26154 "2026-07-09T09:30:34Z")

</div>

Hi everyone! I’d like to share a project I’ve been working on. Smart Chamber Heater is an advanced chamber heating controller for Klipper, designed for enclosed printers using a PTC chamber heater. It supports both…

---

## [ENSURE\_BED\_MESH for Print Start gcode](https://klipper.discourse.group/t/ensure-bed-mesh-for-print-start-gcode/25908)

<div class="topic-metadata">

**Author:** [@sebion7125](https://klipper.discourse.group/u/sebion7125)\
**Replies:** 9\
**Last updated:** [May 12, 2026, 2:54pm UTC](https://klipper.discourse.group/t/ensure-bed-mesh-for-print-start-gcode/25908 "2026-05-12T14:54:06Z")

</div>

I’ve created a macro that ensures there’s a bedmesh active that fits the current bed temperature by naming meshes after bed temperature. I there is no proper one it gets measured with a soak time to ensure there is no dr…

---

## [Faster QUAD\_GANTRY\_LEVEL Macro](https://klipper.discourse.group/t/faster-quad-gantry-level-macro/19044)

<div class="topic-metadata">

**Author:** [@garethky](https://klipper.discourse.group/u/garethky)\
**Replies:** 21\
**Last updated:** [April 8, 2026, 2:31pm UTC](https://klipper.discourse.group/t/faster-quad-gantry-level-macro/19044 "2026-04-08T14:31:32Z")

</div>

Ever wished QGL took less time? The main problem is that the initial probing height needs to be very tall (10mm-20mm) so that the machine doesn’t crash. But after that first course adjustment the machine is usually close…

---

## [TMC2240 use temp for fan control](https://klipper.discourse.group/t/tmc2240-use-temp-for-fan-control/25703)

<div class="topic-metadata">

**Author:** [@nefelim4ag](https://klipper.discourse.group/u/nefelim4ag)\
**Replies:** 0\
**Last updated:** [March 4, 2026, 9:29pm UTC](https://klipper.discourse.group/t/tmc2240-use-temp-for-fan-control/25703 "2026-03-04T21:29:09Z")

</div>

TMC2240 is special. TMC2240 only reports temperature if driver is enabled. Here is an example, based on my setup, where I have glued a thermistor to the X(A) and data from TMC2240: \[display\_template drivers\_fan\] param…

---

## [Klipper Resume After Power Loss Tool GUI Tool](https://klipper.discourse.group/t/klipper-resume-after-power-loss-tool-gui-tool/25351)

<div class="topic-metadata">

**Author:** [@Xboxhacker](https://klipper.discourse.group/u/Xboxhacker)\
**Replies:** 4\
**Last updated:** [January 7, 2026, 1:08pm UTC](https://klipper.discourse.group/t/klipper-resume-after-power-loss-tool-gui-tool/25351 "2026-01-07T13:08:02Z")

</div>

Here is a web-based GUI tool to help you restart your print after a power loss. The tool can be found on my GitHub: Basically, a Python script to edit the gcode file on your Klipper host, then load it to reprint. The…

---

## [Example: Search Printer Objects](https://klipper.discourse.group/t/example-search-printer-objects/164)

<div class="topic-metadata">

**Author:** [@mental](https://klipper.discourse.group/u/mental)\
**Replies:** 3\
**Last updated:** [December 28, 2025, 11:04pm UTC](https://klipper.discourse.group/t/example-search-printer-objects/164 "2025-12-28T23:04:35Z")

</div>

This macro will allow you to type SEARCH\_VARS S={some word} from the terminal and it will respond with all of the matching items in the printer object. Say I wanted to know what the name and path of for the value of th…

---

## [Standalone LINE\_PURGE from KAMP](https://klipper.discourse.group/t/standalone-line-purge-from-kamp/25388)

<div class="topic-metadata">

**Author:** [@hitman47](https://klipper.discourse.group/u/hitman47)\
**Replies:** 0\
**Last updated:** [December 22, 2025, 11:52am UTC](https://klipper.discourse.group/t/standalone-line-purge-from-kamp/25388 "2025-12-22T11:52:58Z")

</div>

Hello. Since Klipper has adaptive meshing integrated now, I wanted to use the awesome purge macro from KAMP without installing all the unnecessary files. So I merged the KAMP\_settings & LINE\_PURGE macro into one simple…

---

## [Automatic backup of save variables file](https://klipper.discourse.group/t/automatic-backup-of-save-variables-file/24729)

<div class="topic-metadata">

**Author:** [@Contomo](https://klipper.discourse.group/u/Contomo)\
**Replies:** 0\
**Last updated:** [September 1, 2025, 5:18pm UTC](https://klipper.discourse.group/t/automatic-backup-of-save-variables-file/24729 "2025-09-01T17:18:06Z")

</div>

This macro is meant to back up your save\_variables file. it runs at every printer startup, and is then scheduled to run every 4 hours. It is checking for atleast 24 hours to have passed, and if the contents of the SVF c…

---

## [Build Sheet Manager & "Adjust Live Z"](https://klipper.discourse.group/t/build-sheet-manager-adjust-live-z/4013)

<div class="topic-metadata">

**Author:** [@garethky](https://klipper.discourse.group/u/garethky)\
**Replies:** 53\
**Last updated:** [August 9, 2025, 3:57pm UTC](https://klipper.discourse.group/t/build-sheet-manager-adjust-live-z/4013 "2025-08-09T15:57:57Z")

</div>

This is a small group of macros that implements Prusa’s Build Sheet system and Adjust Live Z behavior in klipper. Specifically: You can have as many build sheets as you like, each with a unique human readable name Each…

---

## [Inspecting klipper objects and printing contents](https://klipper.discourse.group/t/inspecting-klipper-objects-and-printing-contents/24465)

<div class="topic-metadata">

**Author:** [@Contomo](https://klipper.discourse.group/u/Contomo)\
**Replies:** 0\
**Last updated:** [August 3, 2025, 1:19am UTC](https://klipper.discourse.group/t/inspecting-klipper-objects-and-printing-contents/24465 "2025-08-03T01:19:26Z")

</div>

Yeah i dont know how much more there is to say about this. allows you to lookup objects and look at them, automatically calls methods starting with ‘get\_’ that only take self or eventtime… dunno if that will ever cause …

---

## [Accessing python modules?](https://klipper.discourse.group/t/accessing-python-modules/7090)

<div class="topic-metadata">

**Author:** [@DanS](https://klipper.discourse.group/u/DanS)\
**Replies:** 4\
**Last updated:** [August 3, 2025, 1:41am UTC](https://klipper.discourse.group/t/accessing-python-modules/7090 "2025-08-03T01:41:13Z")

</div>

is there no way of accessing standard python modules within a macro? For example time, timestamp, or math?

---

## [Automatic control of Rectangular HEATBED sections based on PRINT AREA](https://klipper.discourse.group/t/automatic-control-of-rectangular-heatbed-sections-based-on-print-area/3252)

<div class="topic-metadata">

**Author:** [@shreeramlive](https://klipper.discourse.group/u/shreeramlive)\
**Replies:** 6\
**Last updated:** [July 24, 2025, 8:30am UTC](https://klipper.discourse.group/t/automatic-control-of-rectangular-heatbed-sections-based-on-print-area/3252 "2025-07-24T08:30:29Z")

</div>

Our Voron 2.4 printer has 8 (each ~100x100mm) shaped heatbed sections; Arranged in a 4x2 grid, they are controlled by a 8 channel SSR. Each one is 100W AC Silicone pad heater, totaling 800W. There are two SKR 1.3 Boards…

---

## [Macro Creation Tutorial](https://klipper.discourse.group/t/macro-creation-tutorial/30)

<div class="topic-metadata">

**Author:** [@mental](https://klipper.discourse.group/u/mental)\
**Replies:** 45\
**Last updated:** [June 10, 2025, 3:25pm UTC](https://klipper.discourse.group/t/macro-creation-tutorial/30 "2025-06-10T15:25:57Z")

</div>

This is a series of lessons geared to help people understand macro writing in Klipper with the Jinja2 template system.

---

## [Interruptible heat soak](https://klipper.discourse.group/t/interruptible-heat-soak/1552)

<div class="topic-metadata">

**Author:** [@blalor](https://klipper.discourse.group/u/blalor)\
**Replies:** 43\
**Last updated:** [March 24, 2025, 4:02am UTC](https://klipper.discourse.group/t/interruptible-heat-soak/1552 "2025-03-24T04:02:58Z")

</div>

I wanted a macro for heating the bed of my printer and allowing the bed, chamber, and frame to come up to temp for a while. My first solution worked, but M190 and G4 are both blocking commands: it was impossible to inte…

---

## ["Long press" button Macro](https://klipper.discourse.group/t/long-press-button-macro/14901)

<div class="topic-metadata">

**Author:** [@gaolst](https://klipper.discourse.group/u/gaolst)\
**Replies:** 3\
**Last updated:** [March 23, 2025, 5:44pm UTC](https://klipper.discourse.group/t/long-press-button-macro/14901 "2025-03-23T17:44:41Z")

</div>

By default Kliper gcode\_button supports only press and release actions, This configuration allow to extend gcode\_button to recognize how long it was pressed and from that can derive what kind of action it should do, thi…

---

## [Extend RESPOND command with some color options](https://klipper.discourse.group/t/extend-respond-command-with-some-color-options/4158)

<div class="topic-metadata">

**Author:** [@Henlor](https://klipper.discourse.group/u/Henlor)\
**Replies:** 6\
**Last updated:** [January 22, 2025, 5:01am UTC](https://klipper.discourse.group/t/extend-respond-command-with-some-color-options/4158 "2025-01-22T05:01:17Z")

</div>

This macro extend the original Klipper RESPOND command by adding a COLOR parameter. The COLOR parameter adds a css class on the MSG content. Those css classes are already available on Mainsail. This has been designed t…

---

## [G4 Macro to add Param S for seconds](https://klipper.discourse.group/t/g4-macro-to-add-param-s-for-seconds/19548)

<div class="topic-metadata">

**Author:** [@mike\_merryguy](https://klipper.discourse.group/u/mike_merryguy)\
**Replies:** 1\
**Last updated:** [January 6, 2025, 10:19pm UTC](https://klipper.discourse.group/t/g4-macro-to-add-param-s-for-seconds/19548 "2025-01-06T22:19:34Z")

</div>

Simply adds seconds so you don’t have to Math, useful for transitioning from Marlin as they already have P or S in the G4 command. \[gcode\_macro G4\] rename\_existing: G4.1 gcode: {% set SEC = params.S|default(0)|int %} …

---

## [Firmware Retraction for multiple extruders with Z Hop and Swap (Long Retraction)](https://klipper.discourse.group/t/firmware-retraction-for-multiple-extruders-with-z-hop-and-swap-long-retraction/20855)

<div class="topic-metadata">

**Author:** [@tore1887](https://klipper.discourse.group/u/tore1887)\
**Replies:** 5\
**Last updated:** [December 30, 2024, 7:30pm UTC](https://klipper.discourse.group/t/firmware-retraction-for-multiple-extruders-with-z-hop-and-swap-long-retraction/20855 "2024-12-30T19:30:07Z")

</div>

Use: G10 \[(Retraction)\] \[S1 (Long Retraction)\] G11 \[(Recover)\] M207 \[T extruder no.\] \[F retract feedrate\] \[S retract length\] \[W swap retract length\] \[Z z hop height\>\] M208 \[T extruder no.\] \[F recover feedrate\] \[R swap r…

---

## [Mixing Hotend/M163 Emulation](https://klipper.discourse.group/t/mixing-hotend-m163-emulation/11423)

<div class="topic-metadata">

**Author:** [@Corodius](https://klipper.discourse.group/u/Corodius)\
**Replies:** 6\
**Last updated:** [December 21, 2024, 5:02am UTC](https://klipper.discourse.group/t/mixing-hotend-m163-emulation/11423 "2024-12-21T05:02:44Z")

</div>

G’day! I wanted to share my Macro and configuration for a Mixing Hotend, allowing any mix between 2 extruders. There are some caveats to the way this is done, as it is modifying the rotation distance on the fly to chang…

---

## [Display\_template for fan control](https://klipper.discourse.group/t/display-template-for-fan-control/20375)

<div class="topic-metadata">

**Author:** [@Sineos](https://klipper.discourse.group/u/Sineos)\
**Replies:** 0\
**Last updated:** [December 1, 2024, 4:28pm UTC](https://klipper.discourse.group/t/display-template-for-fan-control/20375 "2024-12-01T16:28:06Z")

</div>

Using the quite new display\_template feature for fans, I have created a fan control for my electronics bay. It works similar to what is known from today’s PC mainboards, i.e. you set some temperature interpolation point…

---

## [Macro snippet to calculate the Euclidean distance between filament colors](https://klipper.discourse.group/t/macro-snippet-to-calculate-the-euclidean-distance-between-filament-colors/6033)

<div class="topic-metadata">

**Author:** [@theophile](https://klipper.discourse.group/u/theophile)\
**Replies:** 8\
**Last updated:** [November 28, 2024, 3:41pm UTC](https://klipper.discourse.group/t/macro-snippet-to-calculate-the-euclidean-distance-between-filament-colors/6033 "2024-11-28T15:41:45Z")

</div>

I’m using an X-in-1-out hotend with a purge bucket. Since I don’t have a purge block, I can reduce waste by only purging exactly the amount of filament needed to ensure that the new color/material is fully primed. I have…

---

## [Gcode\_macro MEASURE\_AND\_SET\_Z\_ZERO](https://klipper.discourse.group/t/gcode-macro-measure-and-set-z-zero/19587)

<div class="topic-metadata">

**Author:** [@CrooksUSA](https://klipper.discourse.group/u/CrooksUSA)\
**Replies:** 0\
**Last updated:** [October 23, 2024, 1:17am UTC](https://klipper.discourse.group/t/gcode-macro-measure-and-set-z-zero/19587 "2024-10-23T01:17:22Z")

</div>

I am sharing a macro developed by a very helpful member here ( gaolst): gcode\_macro MEASURE\_AND\_SET\_Z\_ZERO What this macro does is probe the bed in the center only, with a BL Touch prior to each print job; it is embedd…

---

## [Axis Break In macro](https://klipper.discourse.group/t/axis-break-in-macro/19547)

<div class="topic-metadata">

**Author:** [@mike\_merryguy](https://klipper.discourse.group/u/mike_merryguy)\
**Replies:** 0\
**Last updated:** [October 22, 2024, 1:16am UTC](https://klipper.discourse.group/t/axis-break-in-macro/19547 "2024-10-22T01:16:19Z")

</div>

I found this on a facebook group, it was a good idea but he had one for each axis and 100 lines in each one to move it back and forth for him. I use this when I lube my Linear rails often but had been just typing it in …

---

## [Providing Macrofile: Optionally shutdown after printing](https://klipper.discourse.group/t/providing-macrofile-optionally-shutdown-after-printing/2717)

<div class="topic-metadata">

**Author:** [@masterq](https://klipper.discourse.group/u/masterq)\
**Replies:** 28\
**Last updated:** [October 3, 2024, 8:30pm UTC](https://klipper.discourse.group/t/providing-macrofile-optionally-shutdown-after-printing/2717 "2024-10-03T20:30:45Z")

</div>

Hi \*, I have written some macro code that allows to shut down the printer after a print is completed. It can be dynamical set while printing. It’s rarely tested but what tested did work. Follow the instructions at the …

---

## [Call back using moonraker API to Klipper macro](https://klipper.discourse.group/t/call-back-using-moonraker-api-to-klipper-macro/18013)

<div class="topic-metadata">

**Author:** [@oernster](https://klipper.discourse.group/u/oernster)\
**Replies:** 0\
**Last updated:** [August 1, 2024, 3:22am UTC](https://klipper.discourse.group/t/call-back-using-moonraker-api-to-klipper-macro/18013 "2024-08-01T03:22:24Z")

</div>

I use this with my previous guide here but you could do your own beepy solution if you prefer or just call your own MACRO from a shell script and python script from there: This is the handy moonraker API calling pytho…

---

## [Poviding Macro: M600 macro with message on screen, similar to marlin](https://klipper.discourse.group/t/poviding-macro-m600-macro-with-message-on-screen-similar-to-marlin/17823)

<div class="topic-metadata">

**Author:** [@Maguz1024](https://klipper.discourse.group/u/Maguz1024)\
**Replies:** 0\
**Last updated:** [July 22, 2024, 10:09pm UTC](https://klipper.discourse.group/t/poviding-macro-m600-macro-with-message-on-screen-similar-to-marlin/17823 "2024-07-22T22:09:36Z")

</div>

M600 COMMAND WITH MESSAGE ON SCREEN Displays a message on the web screen interactively, similar to the marlin M600 command, with the following options: 1 unload filament 2 load filament 3 button to perform 20mm PURGE…

---

## [Macro to change the feedrate based on the featuretype](https://klipper.discourse.group/t/macro-to-change-the-feedrate-based-on-the-featuretype/17084)

<div class="topic-metadata">

**Author:** [@WatchingWatches](https://klipper.discourse.group/u/WatchingWatches)\
**Replies:** 0\
**Last updated:** [June 16, 2024, 12:35pm UTC](https://klipper.discourse.group/t/macro-to-change-the-feedrate-based-on-the-featuretype/17084 "2024-06-16T12:35:26Z")

</div>

Klipper Custom Feature Speed The script and all other information can be found here Introduction: This postprocessing script in combination with a Klipper macro enables the user to change the printing speed based on the…

---

## [\`ADJUST\_M106\` - A Comprehensive Part Cooling Modifier](https://klipper.discourse.group/t/adjust-m106-a-comprehensive-part-cooling-modifier/4360)

<div class="topic-metadata">

**Author:** [@garethky](https://klipper.discourse.group/u/garethky)\
**Replies:** 21\
**Last updated:** [June 8, 2024, 6:35am UTC](https://klipper.discourse.group/t/adjust-m106-a-comprehensive-part-cooling-modifier/4360 "2024-06-08T06:35:24Z")

</div>

If you have ever tried to save a print with too much or too little part cooling you may have tried the fan slider in Fluidd or Mainsail and been disappointed. Your changes wont stay for long because modern slicers are co…

[Next page](https://klipper.discourse.group/c/macros/8.md?page=1)
