Skip to content

Converting to Dynamic Macros

Follow this tutorial to convert your standard gcode_macro to a Dynamic Macro.

printer.cfg

First, remove the include line in your printer.cfg referencing the file your macros are in. For example, if your macros are in macros.cfg, remove the line:

[include macros.cfg]

from your printer.cfg.

Dynamic Macros Configuration

Next, if you don't already have one, create a [dynamicmacros] config section in your printer.cfg and add your macro configuration to it:

printer.cfg
1
2
3
[dynamicmacros]
config_path: ~/printer_data/config # If you left your printer configuration path as the default, you don't need to specify this
configs: macros.cfg # You can add more files to this list, separated by commas.
KlipperScreen

If you convert your LOAD_FILAMENT and UNLOAD_FILAMENT macros to be dynamic, KlipperScreen may not recognize them and report an error. To fix this, add blank macros to your printer.cfg, before your [dynamicmacros] section. Example:

printer.cfg
1
2
3
4
5
6
[gcode_macro LOAD_FILAMENT]
gcode:
    M117 LOAD
[gcode_macro UNLOAD_FILAMENT]
gcode:
    M117 UNLOAD

Unknown config object 'gcode_macro'

If you are getting a "Unknown config object 'gcode_macro'" error after converting your macros to Dynamic Macros, move your [dynamicmacros] section to be after your [virtual_sdcard] section.

Fluidd

Fluidd may not display macros after install DynamicMacros. As a workaround, you can switch to Mainsail, or define a standard gcode_macro, then override it in a dynamic macro. Example:

normal_macros.cfg
1
2
3
[gcode_macro HELLO]
gcode:
    RESPOND MSG="" # Dummy GCode to be overriden by a Dynamic Macro
dynamic_macros.cfg
1
2
3
[gcode_macro HELLO]
gcode:
    RESPOND MSG="Hello"
Nacro Names

Klipper has certain macro names reserved for core functionality. If you are experiencing errors, don't name your Dynamic Macros any of the following:

  • PAUSE
  • RESUME
  • CANCEL_PRINT

If you want to make those macros dynamic, first define them as a standard GCode macro:

1
2
3
[gcode_macro PAUSE]
gcode:
    DYNAMIC_PAUSE

Restart Klipper.

That's it. Your macros are now Dynamic Macros.

Comments