def execute(self, data):
if self.getSettingValueByKey("name") != "":
name = self.getSettingValueByKey("name")
else:
name = Application.getInstance().getPrintInformation().jobName
lcd_text = "M117 " + " layer %d/%d"
i = 1
layers = 0
for layer in data:
display_text = lcd_text % (i, layers)
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
elif line.startswith(";LAYER_COUNT:"):
layers = int(line[13:])
final_lines = "\n".join(lines)
data[layer_index] = final_lines
return data
Starts at layer 1 isntead of 0
Extracts the layercount from the gcode.