Jump to content
Ultimaker Community of 3D Printing Experts
Sign in to follow this  
jeroen-somers

Plugin question

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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?

 

Share this post


Link to post
Share on other sites

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.

 

Share this post


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
Sign in to follow this  

  • Our picks

    • Taking Advantage of DfAM
      This is a statement that’s often made about AM/3DP. I'll focus on the way DfAM can take advantage of some of the unique capabilities that AM and 3DP have to offer. I personally think that the use of AM/3DP for light-weighting is one of it’s most exciting possibilities and one that could play a key part in the sustainability of design and manufacturing in the future.
        • Like
      • 3 replies
×

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!