Jump to content
Ultimaker Community of 3D Printing Experts

Cura Plugin - Display Filename and Layer on LCD


RadioDoc
 Share

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
clarity
  • 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")
            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.

  • 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
     Share

    • Our picks

      • The Ultimaker Showcase — October 14. What's new?
        Your dear friends at Ultimaker have some exciting news and insights for you!
         
        • 0 replies
      • New here? Get ahead with a free onboarding course
        Hi,
         
        Often getting started is the most difficult part of any process. A good start sets you up for success and saves you time and energy that could be spent elsewhere. That is why we have a onboarding course ready for
        Ultimaker S5 Pro Bundle, Ultimaker S5, Ultimaker S3 Ultimaker 2+ Connect.   
        They're ready for you on the Ultimaker Academy platform. All you need to do to gain access is to register your product to gain free access. 
        Ready? Register your product here in just 60 seconds.
          • Like
        • 8 replies
    ×
    ×
    • Create New...