Why macro names like T0 do not work

On GH there was a remarkably good explanation by @simonkuehling regarding macro naming conventions. Pulled over here for future reference

Background

A differentiation has to be made between:

Following is quoted from a.m. GH link:

[…] The traditional syntax of gcode commands does not allow for “parameter=foobar” notation. The “extended gcode” format of commands was introduced by Klipper and cannot be mixed with the traditional syntax.

You can use your own parameters with a macro in the traditional gcode style like T0, too - if you stick to the [single character][number] syntax (Like T0 S0 ) - but you cannot pass strings to the macro this way.

The problem is not the number at the end - but if it is a single character followed by a number, then it is parsed as a traditional style command:

[gcode_macro TF2]
gcode:
    { action_respond_info(params.FILAMENT) }

executed as TF2 FILAMENT="hello" does work, for example.

Example of a filament switching request in Prusa Slicer:

Macro definition in Klipper

[gcode_macro T0]
gcode:
    # do nothing

[gcode_macro T1]
gcode:
    # do nothing

[gcode_macro REQUEST_CHANGE]
gcode:
{% set filament = params.FILAMENT|default("") %}
{% set string_output = "Please load " ~ filament ~ " Filament" %}
PAUSE
{ action_respond_info(string_output) }

Calling the macro in Prusa Slicer

T[next_extruder]
REQUEST_CHANGE FILAMENT="[filament_settings_id]"
1 Like