fieldOfView / Cura-OctoPrintPlugin

Cura plugin which enables printing directly to OctoPrint and monitoring the process
GNU Affero General Public License v3.0
493 stars 74 forks source link

[Request] Add plugin comment to uploaded gcode #203

Open FormerLurker opened 3 years ago

FormerLurker commented 3 years ago

Hi! I was wondering if you would be willing to add a single comment to the top of files uploaded to OctoPrint that could be used to indicate that the file was uploaded via your plugin. Something like this maybe:

; Uploaded by the Cura-OctoPrintPlugin

This would allow my plugin, ArcWelder, to detect that a file was uploaded via your plugin, and to process the file accordingly. A bonus would be to also add an indication that the print will be auto-started:

; Uploaded by the Cura-OctoPrintPlugin - Print After Upload

Though that is not as important. Anyway, thank you for considering this!

fieldOfView commented 3 years ago

This would allow my plugin, ArcWelder, to detect that a file was uploaded via your plugin,

What would be the difference between uploading with my plugin and uploading manually?

Can my plugin somehow see that your plugin is done processing the gcode file? Then it can handle the "print after upload" by itself, similarly how it waits for the PrintTimeGenius plugin to do its processing.

fieldOfView commented 3 years ago

On a totally unrelated note, a Cura plugin that implements your ArcWelder as a postprocessor is still on my todo list.

FormerLurker commented 3 years ago

Then it can handle the "print after upload" by itself, similarly how it waits for the PrintTimeGenius plugin to do its processing.

PrintTimeGenius uses the gcode analysis hook I believe. I had a lot of trouble with that method and abandoned it eventually since ArcWelder can both modify the source file and create a new file with a pre/postfix. However, I'm open to any suggestions for how to accomplish this.

FYI, I've added the ability to add settings for arc-welder directly to the gcode file. Things like 'print after processing' and conversion settings. I've got some capability to detect slicer uploads if the gcode file contains any unique comments indicating where it came from.

Regarding the postprocessor, someone sent me a py file that actually works with the postprocessing plugin. I'm going to parallelize it so that it can slice multiple layers at the same time, which should be fast enough to make it work like a regular postprocessor. It would still be nice for it to be a full blown plugin though.

fieldOfView commented 3 years ago

I have no problem with adding a comment to the uploaded gcode to identify the plugin, but I find adding a "print after upload" flag to the gcode an ugly hack. That flag only ever makes sense right after uploading, but remains in the gcode file on the OctoPrint instance.

I would rather poll an endpoint to see if ArcWelderPlugin is done processing the file, or tell ArcWelderPlugin to start the print after processing with an API call to the ArcWelderPlugin.

FormerLurker commented 3 years ago

Maybe I can just provide an api call? Something like /arcwelder/printAfterProcessing? Internally I would check the processing queue to see if the provided path is in there, and if it is it will mark it to print after processing. If not, it could return is_queued=false or 404 if the plugin is not found.

If something like this will work, I'll add the call and will provide a definition.

fieldOfView commented 2 years ago

I forgot to respond to your last reply.

If something like this will work, I'll add the call and will provide a definition.

That would work.