From b0493ed126eb273ef6bcd4435f6faf0e99b01ac3 Mon Sep 17 00:00:00 2001 From: Olivier B Date: Sat, 10 Jan 2026 16:17:42 +0100 Subject: [PATCH] Add multiline support for custom G-code in FilamentChange Updated G-code macros to support multiline input using '|' character. --- plugins/PostProcessingPlugin/scripts/FilamentChange.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/FilamentChange.py b/plugins/PostProcessingPlugin/scripts/FilamentChange.py index f51ba73ffb..fa2fbbbb0e 100644 --- a/plugins/PostProcessingPlugin/scripts/FilamentChange.py +++ b/plugins/PostProcessingPlugin/scripts/FilamentChange.py @@ -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"