Jump to content

Cura Plugin - Display Filename and Layer on LCD

Recommended Posts

Posted (edited) · Cura Plugin - Display Filename and Layer on LCD

I've been poking around at the Display Filename And Layer On LCD plugin because it wasn't functioning properly with my FLSUN FL-K Base Delta (it would display the text string and layer, but not the number).  For whatever reason, Marlin bugfix-1.1.x didn't like showing any text after the colon, and after a bit of trial and error, I figured out where to remove the colon that was preventing the layer number from popping up on the LCD.  That got me to thinking about how to get the plugin to display the current layer and the total number of layers.  Unfortunately, my knowledge of python is non-existent, and while I know enough from other languages (namely VBA), what I can't figure out is how to get the total number of layers from the application.  Can anyone point me to the documentation or toss me a text string of what I need to use?

Specifically, I'm looking at line 42 of DisplayFilenameAndLayerOnLCD.py, and want to edit it to "display_text = lcd_text + str(i) + total_layers", where total_layers is a string containing either "/" or " of " and the total layer count for the print.  I just need to figure out how to get the total layer count.  I can see that it's generated when I look at the gcode, but what is the variable that defines that?

Edited by RadioDoc

Share this post

Link to post
Share on other sites
Posted · Cura Plugin - Display Filename and Layer on LCD
    def execute(self, data):
        if self.getSettingValueByKey("name") != "":
            name = self.getSettingValueByKey("name")
            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.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Our picks

    • Ultimaker Cura 4.0 | Stable available!
      Ultimaker Cura 4.0 is mainly focused on the improved user interface and cloud integration.
      As always, we want to collect your user feedback for this release. If there are any improvements you can think of, feel free to mention it here and help us to shape the next release.
      • 98 replies
  • Create New...

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!