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
  • Link to post
    Share on other sites

    • 4 months later...
    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.

  • Link to post
    Share on other sites

    • 5 months later...
    Posted · Cura Plugin - Display Filename and Layer on LCD

    Hi RadioDoc. Unless I'm mistaken (which is very possible) you are looking for the variable  max_layer.  I have other issues with this plug-in, which I'll raise in a separate post. hope thius helps. I note this is an old post, so you've probably sorted it by now.

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.4 stable released
        The full stable release of UltiMaker Cura 5.4 is here and it makes it easier than ever to remove brims and supports from your finished prints. UltiMaker S series users can also look forward to print profiles for our newest UltiMaker PET CF composite material!
        • 58 replies
    • Create New...