Jump to content

Plugin question


jeroen-somers

Recommended Posts

Posted · Plugin question

Hi there all,

I don't know if its been asked before (I've looked but couldn't find it).

I am writing a Cura Plugin to display the current .gcode file that is selected from the SD card.

Only I can't get the plugin working so maybe you could help me out here.

What I want is that the message >> M117 Printing... <<

is replaced with >> M117 ("filename".gcode) <<

This is my plugin so far:

--------------------------------------

#Name: Display Name

#Info: Shows the name of the file on the display.

#Type: postprocess

import re, os.path

def getFilename():

return os.path.basename(filename)

with open(filename, "r") as f:

lines = f.readlines()

with open(filename, "w") as f:

for line in lines:

if line.startswith('M117'):

filename = getFilename()

f.write("M117 " + filename + '\n')

else :

f.write(line)

-------------------------------------

what it does, it replaces the printing message > M117 Printing...

with this >> M117 CuraPluginTempz3u6ub

This isn't my ("filename".gcode)

This is some random temp file that is made when you save your cura model to .gcode

If you need more information just say so.

I hope someone can help me with this

With kind regards,

Jeroen Somers

 

  • Link to post
    Share on other sites

    Posted · Plugin question

    The plugin runs before you save the file. Therefore it cannot know the final filename. The only thing it can know is the name of the temporary file created by Cura and handed over to the plugin.

     

  • Link to post
    Share on other sites

    Posted · Plugin question

    The plugin runs before you save the file. Therefore it cannot know the final filename. The only thing it can know is the name of the temporary file created by Cura and handed over to the plugin.

     

    But the filename is created by the model you load, this model has a name and when you save it it becomes (modelname.gcode). And the model is loaded before the Plugin.

    Isn't there a way to get this name?

     

  • Link to post
    Share on other sites

    Posted · Plugin question

    A simple solution could be if cura would create a random directory and give the file its normal basename. But yeah, this might need some cura changes. At some point the start.gcode had placeholders for the filename, but they were never replaced with the actual filename.

     

  • 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

      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Thanks
          • Like
        • 3 replies
      • UltiMaker Cura 5.7 stable released
        Cura 5.7 is here and it brings a handy new workflow improvement when using Thingiverse and Cura together, as well as additional capabilities for Method series printers, and a powerful way of sharing print settings using new printer-agnostic project files! Read on to find out about all of these improvements and more. 
         
          • Like
        • 26 replies
    ×
    ×
    • Create New...