mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
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
This commit is contained in:
parent
694cc91ae9
commit
6dbf0a5fb7
1 changed files with 50 additions and 0 deletions
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue