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

      • 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
        • 18 replies
      • S-Line Firmware 8.3.0 was released Nov. 20th on the "Latest" firmware branch.
        (Sorry, was out of office when this released)

        This update is for...
        All UltiMaker S series  
        New features
         
        Temperature status. During print preparation, the temperatures of the print cores and build plate will be shown on the display. This gives a better indication of the progress and remaining wait time. Save log files in paused state. It is now possible to save the printer's log files to USB if the currently active print job is paused. Previously, the Dump logs to USB option was only enabled if the printer was in idle state. Confirm print removal via Digital Factory. If the printer is connected to the Digital Factory, it is now possible to confirm the removal of a previous print job via the Digital Factory interface. This is useful in situations where the build plate is clear, but the operator forgot to select Confirm removal on the printer’s display. Visit this page for more information about this feature.
          • Like
        • 0 replies
    ×
    ×
    • Create New...