Add multiline support for custom G-code in FilamentChange

Updated G-code macros to support multiline input using '|' character.
This commit is contained in:
Olivier B 2026-01-10 16:17:42 +01:00 committed by GitHub
parent f7bdc51856
commit b0493ed126
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,8 @@
# Modification 06.09.2020
# add checkbox, now you can choose and use configuration from the firmware itself.
# Modification 10.01.2026
# add multiline in custom G-code, using '|' character.
from typing import List
from ..Script import Script
@ -135,7 +137,7 @@ class FilamentChange(Script):
"before_macro":
{
"label": "G-code Before",
"description": "Any custom G-code to run before the filament change happens, for example, M300 S1000 P10000 for a long beep.",
"description": "Any custom G-code to run before the filament change happens, for example, M300 S1000 P10000 for a long beep. Use '|' to separate lines.",
"unit": "",
"type": "str",
"default_value": "M300 S1000 P10000",
@ -152,7 +154,7 @@ class FilamentChange(Script):
"after_macro":
{
"label": "G-code After",
"description": "Any custom G-code to run after the filament has been changed right before continuing the print, for example, you can add a sequence to purge filament and wipe the nozzle.",
"description": "Any custom G-code to run after the filament has been changed right before continuing the print, for example, you can add a sequence to purge filament and wipe the nozzle. Use '|' to separate lines.",
"unit": "",
"type": "str",
"default_value": "M300 S440 P500",
@ -197,7 +199,7 @@ class FilamentChange(Script):
color_change = ";BEGIN FilamentChange plugin\n"
if enable_before_macro:
color_change = color_change + before_macro + "\n"
color_change = color_change + before_macro.replace('|', '\n') + "\n"
color_change = color_change + "M600"
@ -223,7 +225,7 @@ class FilamentChange(Script):
color_change = color_change + "\n"
if enable_after_macro:
color_change = color_change + after_macro + "\n"
color_change = color_change + after_macro.replace('|', '\n') + "\n"
color_change = color_change + ";END FilamentChange plugin\n"