Jump to content
Sign in to follow this  
jeroen-somers

Plugin question

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

 

Share this post


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.

 

Share this post


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?

 

Share this post


Link to post
Share on other sites
Posted · Plugin question

Not at the moment as far as I know. Cura would have to pass the model name over to the plugin. Daid might prove me wrong.

 

Share this post


Link to post
Share on other sites
Posted · Plugin question

You could do it post save instead of with a plugin. This way you can open the saved file and change it.

Look for _saveGCode function in Cura/gui/sceneView.py

 

Share this post


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.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Our picks

    • Ultimaker Cura 4.0 | Stable available!
      Ultimaker Cura 4.0 is mainly focused on the improved user interface and cloud integration.
      As always, we want to collect your user feedback for this release. If there are any improvements you can think of, feel free to mention it here and help us to shape the next release.
      • 11 replies
×
×
  • Create New...

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!