Klipper Dynamic Macros
Never restart Klipper again for simple macros.

Klipper Dynamic Macros is an unofficial way to update macros without restarting Klipper, so you can update macros mid-print and see their results live. It also supports many extra features that normal GCode Macros don't have.
Features
-
Recursion
Allow macros to call themselves internally for more complex logic.
-
Receiving Variables
Allow macros to update their state while running.
-
Utility Functions
Reusable helpers and shared logic for complex macro systems.
-
Variables & State
Persistent variables and runtime state across macro executions.
-
Embedded Python
Use Python expressions and helpers directly inside macros.
-
Rendering & Templating
Render your macros before running them to quickly iterate on logic.
-
Delayed GCode
All the above features are also available in
delayed_gcodesections. -
Macro Clusters
Group related macros into structured, modular systems, with optional safety systems in place.
| Normal Macro | Dynamic Macro |
|---|---|
| Macros read once from configuration file | Macros read once then reloaded on demand |
| Requires restart to update macros | Updates macros on demand |
| Does not support recursion | Allows recursion |
| Internal state is fixed within macro run | Internal state can be updated during macro run |
| Does not allow pre-rendering macros | Allows pre-rendering macros |
Info
Unlike traditional G-Code macros, Dynamic Macros are not included in your printer.cfg and are instead defined in a separate file. They are instead read by a [dynamicmacros] section in your printer.cfg.
Klippy Extras Tutorial
DynamicMacros also includes a tutorial on writing Klippy extras.
Examples
See Example Macros for examples of Dynamic Macros.
More Projects
If you like this project, don't forget to give it a star! Also, check out the 3MS, a modular multimaterial system for Klipper!
