Way to post/pre process gcode through moonraker?

Hey, i forked the moonraker repo here : GitHub - CooperGerman/moonraker_spoolman_enhancement: Web API Server for Klipper with spoolman enhancement for mmu setups and automatic filament selection...

This repo primarly updates metadata.py for filament usage extraction purposes and spoolman.py to make use of it and add functionality to the module.

Feel free to explore, here are the macros i added to use the updated spoolman.py :


[gcode_macro SET_ACTIVE_SPOOL]
description: Sets active spool to spool with given id.
  Usage: SET_ACTIVE_SPOOL [ID=<int>]
gcode:
    {% if params.ID %}
        {% set id = params.ID|int %}
        {action_call_remote_method(
        "spoolman_set_active_spool",
        spool_id=id
        )}
    {% else %}
        {action_respond_info("Parameter 'ID' is required")}
    {% endif %}

[gcode_macro SET_ACTIVE_SLOT]
description: Sets active spool at slot <SLOT> as active spool.
  Usage: SET_ACTIVE_SPOOL [SLOT=<int>]
gcode:
    {% if params.SLOT %}
        {% set slot = params.SLOT|int %}
        {action_call_remote_method(
        "spoolman_set_active_slot",
        slot=slot
        )}
    {% else %}
        {action_respond_info("Parameter 'ID' is required")}
    {% endif %}

[gcode_macro GET_SPOOL_INFO]
description: Gets information for active spool if no id given else information of spool with given id.
  Usage: GET_SPOOL_INFO [ID=<int>]
gcode:
    # Dummy block for mainsail
    {% set id = None %}
    {% if params.ID %}
        {% set id = params.ID|int %}
    {% endif %}
    {action_call_remote_method("spoolman_get_spool_info",id=id)}

[gcode_macro SET_SPOOL_SLOT]
description: Assigns spool id=ID to current machine. If MMU is enabled slot number must be specified with SLOT=<int>.
  Usage: SET_SPOOL_SLOT [ID=<int>]
                        [SLOT=<int>]
gcode:
    {% set id = None %}
    {% set slot = None %}
    {% if params.ID %}
        {% set id = params.ID|int %}
    {% endif %}
    {% if params.SLOT %}
        {% set slot = params.SLOT|int %}
    {% endif %}
    {action_call_remote_method("spoolman_set_spool_slot",spool_id=id, slot=slot)}

[gcode_macro GET_SPOOLS]
description: Gets all spools assigned to current machine.
  Usage: GET_SPOOLS
gcode:
    {action_call_remote_method("spoolman_get_spools_for_machine")}

[gcode_macro CHECK_FILAMENT]
description: Proceeds to checks several aspects of currently loaded filaments and selected fialement for current print.
    Usage : CHECK_FILAMENT [DEBUG=<int>]
gcode:
    {action_call_remote_method("spoolman_check_filament",debug=params.DEBUG|default(0)|int)}

[gcode_macro CLEAR_ACTIVE_SPOOL]
description: Clears active spool.
  Usage: CLEAR_ACTIVE_SPOOL
gcode:
    {action_call_remote_method(
        "spoolman_set_active_spool",
        spool_id=None
    )}

[gcode_macro CLEAR_SPOOL_SLOTS]
description: Clears all spool slots.
  Usage: CLEAR_SPOOL_SLOTS
gcode:
    {action_call_remote_method("spoolman_clear_spool_slots")}

Not everything is in a publish ready state but feel free to snoop around and ask for clarifications :wink: