From 6dbf0a5fb705f36547c794c42ea7d8c3c69a4fa0 Mon Sep 17 00:00:00 2001 From: Amanda de Castilho Date: Wed, 29 Aug 2018 00:39:13 -0700 Subject: [PATCH 1/4] Create DisplayFilenameAndLayerOnLCD This plugin inserts M117 into the g-code so that the filename is displayed on the LCD and updates at each layer to display the current layer --- .../scripts/DisplayFilenameAndLayerOnLCD | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD diff --git a/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD b/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD new file mode 100644 index 0000000000..f7ddd01e1e --- /dev/null +++ b/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD @@ -0,0 +1,50 @@ +# Cura PostProcessingPlugin +# Author: Amanda de Castilho +# Date: August 28, 2018 + +# Description: This plugin inserts a line at the start of each layer, +# M117 displays the filename and layer height to the LCD +# ** user must enter 'filename' +# ** future update: include actual filename + +from ..Script import Script + +class DisplayFilenameAndLayerOnLCD(Script): + def __init__(self): + super().__init__() + + def getSettingDataString(self): + return """{ + "name": "Display filename and layer on LCD", + "key": "DisplayFilenameAndLayerOnLCD", + "metadata": {}, + "version": 2, + "settings": + { + "name": + { + "label": "filename", + "description": "Enter filename", + "type": "str", + "default_value": "default" + } + } + }""" + + def execute(self, data): + name = self.getSettingValueByKey("name") + lcd_text = "M117 " + name + " layer: " + i = 0 + for layer in data: + display_text = lcd_text + str(i) + layer_index = data.index(layer) + lines = layer.split("\n") + for line in lines: + if line.startswith(";LAYER:"): + line_index = lines.index(line) + lines.insert(line_index + 1, display_text) + i += 1 + final_lines = "\n".join(lines) + data[layer_index] = final_lines + + return data From a5baa9008637b7f28a9c5c198671f8bb492c2930 Mon Sep 17 00:00:00 2001 From: Amanda de Castilho Date: Wed, 29 Aug 2018 08:09:57 -0700 Subject: [PATCH 2/4] Rename DisplayFilenameAndLayerOnLCD to DisplayFilenameAndLayerOnLCD.py added the .py extention --- ...splayFilenameAndLayerOnLCD => DisplayFilenameAndLayerOnLCD.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/PostProcessingPlugin/scripts/{DisplayFilenameAndLayerOnLCD => DisplayFilenameAndLayerOnLCD.py} (100%) diff --git a/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD b/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py similarity index 100% rename from plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD rename to plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py From f7fbc685d8ffa8ebebc7aa887e4045a6a373d2d8 Mon Sep 17 00:00:00 2001 From: Amanda de Castilho Date: Wed, 29 Aug 2018 08:43:16 -0700 Subject: [PATCH 3/4] Update DisplayFilenameAndLayerOnLCD.py changed so that actual filename is displayed (or alternatively user can enter text to display) to LCD during print --- .../scripts/DisplayFilenameAndLayerOnLCD.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py b/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py index f7ddd01e1e..2ae07f914c 100644 --- a/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py +++ b/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py @@ -3,11 +3,11 @@ # Date: August 28, 2018 # Description: This plugin inserts a line at the start of each layer, -# M117 displays the filename and layer height to the LCD -# ** user must enter 'filename' -# ** future update: include actual filename +# M117 - displays the filename and layer height to the LCD +# Alternatively, user can override the filename to display alt text + layer height -from ..Script import Script +..Script import Script +from UM.Application import Application class DisplayFilenameAndLayerOnLCD(Script): def __init__(self): @@ -23,16 +23,19 @@ class DisplayFilenameAndLayerOnLCD(Script): { "name": { - "label": "filename", - "description": "Enter filename", + "label": "text to display:", + "description": "By default the current filename will be displayed on the LCD. Enter text here to override the filename and display something else.", "type": "str", - "default_value": "default" + "default_value": "" } } }""" def execute(self, data): - name = self.getSettingValueByKey("name") + if self.getSettingValueByKey("name") != "": + name = self.getSettingValueByKey("name") + else: + name = Application.getInstance().getPrintInformation().jobName lcd_text = "M117 " + name + " layer: " i = 0 for layer in data: From 7e7f2aab6b9846ca9235d302250308c50c94a10c Mon Sep 17 00:00:00 2001 From: Amanda de Castilho Date: Wed, 29 Aug 2018 09:48:37 -0700 Subject: [PATCH 4/4] Update DisplayFilenameAndLayerOnLCD.py --- .../scripts/DisplayFilenameAndLayerOnLCD.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py b/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py index 2ae07f914c..9fd9e08d7d 100644 --- a/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py +++ b/plugins/PostProcessingPlugin/scripts/DisplayFilenameAndLayerOnLCD.py @@ -6,7 +6,7 @@ # M117 - displays the filename and layer height to the LCD # Alternatively, user can override the filename to display alt text + layer height -..Script import Script +from ..Script import Script from UM.Application import Application class DisplayFilenameAndLayerOnLCD(Script):