cameroncros / OctoPrint-DiscordRemote

Discord plugin for OctoPrint
MIT License
66 stars 34 forks source link

Embed GCODE Thumbnail #218

Open Dealman opened 2 years ago

Dealman commented 2 years ago

Is your feature request related to a problem? Please describe. No.

Describe the solution you'd like It's possible to have slicers include a small thumbnail of the model, stored in the GCODE file. It would be real neat if we could have the option to embed this thumbnail when a print is started - instead of showing a still of the printer.

Describe alternatives you've considered None.

Additional context This is enabled like this in Cura: image

Dealman commented 2 years ago

The data for the thumbnail is commented out in the GCODE file and looks like this;

;Generated with Cura_SteamEngine 4.13.1
;
; thumbnail begin 128 128 6344
; iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAA7EAAAOxAGVKw4bAAASR0
; lEQVR4nO2deXBc1ZWHf+e+14t2WbItjG1sZEOwsSSbEAaCA2EmBAhgmyQsScw2A0VSU2QmIQ6ZGmoM
; WYqaxOUswzbMVM1MqiCxmcAYMIaQsEi2WWyDdyTLixZLrdZmWVur33LP/PG6pe5Wt3pRt2ST+7muen
; vLueece+695933DCgUCoVCoVAoFAqFQqFQKBQKhUKhUCgUCoVCoVAoFAqFQqFQKBQKhUKhUCgUCoVC
; oVAoFAqFQqFQKBQKheIMhaZbgDOJ/1q/0JtXWPwQgJuJMR8EMHMLEb3e4vdvWLfBPxTedv16iAvyF5
; +79uGjJ6dR5EmjHCDEXbfMLf/cRSVbzinXr5Qc/RsB6Om3dwnC/5QUUhVLWg6gCsR5LOm3AzT0Dw/8
; 6Pjp6ZB7sigHCPH4Py6574oq739UnqvDAjAkCcwMLwFuAlo6LNQ3GyjKF3H2pmaGvP+bDx98c6rlni
; x/sQ6wef1St+UWFwmXWA7mmoYW80tLFrqqVy7Pw8wKHXqxCwAgBy2c6rLwwcER7GsMYtE8d4IjsgTw
; n0Ns/ODvHm4YmLKKTJK/CAfYvHFpGSytygYuEYQaBlUTeCmYPOFtGk8aKC/RULPYjYoyDQV5TksfGm
; F09lo4eMyAv9fG4vmJHCAEoV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2enP+cVOsuYdgcAgHvWLHoQhF8vnOOiL12WN/pwSQDx5+DgqAFbfZOBhh
; YzMDgs94BQSzbvGDaM7b29vf1TWpGzkDPCAQDg3lsW/RTAP6++uhCzZmjj5uGBoAxfHcMnTQaOt5n9
; wSDvDC16qPP5fLuQYNGDIjFnjAMAwD23LHp29dWF988u1dA/JFHfZOBwk4EjzSZOtJvdkrmWJbZLoN
; bn8+3Dp3yEPhWcUf9lzIKXjn17b8VFPW98MHR/q98aAKEOEtuZ6N329vaG6ZZPMXWcASv6FAqFQqFQ
; KBQKhUKhUCgUCoVCoVAoFAqFQqFQKBQKhUKhUCgUCoVCoVAoFAqFQqFQKBQKhUKhUCgUCoViuvl/rn
; YD2CbM2w4AAAAASUVORK5CYII=
; thumbnail end
;
cameroncros commented 2 years ago

If you want to add this feature, that would be great. I am happy to merge new features, but I wont development them myself.

Dealman commented 2 years ago

Uh I might have a look at it, I've never worked on a plugin for OctoPrint before so it would be quite the journey to learn how to go about testing to make sure it works before I make a PR.

That said, it should be a rather easy implementation so long as all the slicers follow the same concept.

cameroncros commented 2 years ago

It isn't terribly difficult if you have python ability, I just don't have a lot of time to do it myself. I'll leave this ticket open in case you or someone else wants to work on it

Dealman commented 2 years ago

I'm not a huge fan of Python but I know my way around it, if you could help me out with a few pointers I could probably have a go at implementing this later as I think it's a pretty neat feature. It may also be possible to do this via scripts, I guess? I set allow_scripts to true - but am unable to find documentation on how to work with this;

Here you can specify a file to be executed before and after each message is sent to Discord. The file should be executable by the user under which OctoPrint is running

Would this be the place where one would implement a method, for example get_thumbnail? If yes, how would I go about fetching the GCODE to parse it when a print is started?

https://github.com/cameroncros/OctoPrint-DiscordRemote/blob/de7962a0dddec7928a281c451de971b5b7d3ce97/octoprint_discordremote/__init__.py#L530

cameroncros commented 1 year ago

For what it's worth, I didn't know/use python before I took on this project either in the first place.

I don't really know what the scripts stuff is for to be honest, it was already part of the old plugin, and I don't know if it still works or not.

I would start looking around here: https://github.com/cameroncros/OctoPrint-DiscordRemote/blob/master/octoprint_discordremote/__init__.py#L506

You probably want to add a special case for "printing_started" (see on_event function for all events), and add a get_thumbnail function that gets called there. I dunno how to get to the gcode file and pull out the thumbnail, you may have to work that out yourself. There is octoprint plugin development doco somewhere that will help you though.

https://docs.octoprint.org/en/master/plugins/index.html

On Sat, 30 Apr 2022, 9:58 pm Dennis, @.***> wrote:

I'm not a huge fan of Python but I know my way around it, if you could help me out with a few pointers I could probably have a go at implementing this later as I think it's a pretty neat feature. It may also be possible to do this via scripts, I guess? I set allow_scripts to true - but am unable to find documentation on how to work with this;

Here you can specify a file to be executed before and after each message is sent to Discord. The file should be executable by the user under which OctoPrint is running

Would this be the place where one would implement a method, for example get_thumbnail? If yes, how would I go about fetching the GCODE to parse it when a print is started?

https://github.com/cameroncros/OctoPrint-DiscordRemote/blob/de7962a0dddec7928a281c451de971b5b7d3ce97/octoprint_discordremote/__init__.py#L530

— Reply to this email directly, view it on GitHub https://github.com/cameroncros/OctoPrint-DiscordRemote/issues/218#issuecomment-1113976024, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK7FL6AFIQU3G7YNIUWIQLVHUN6RANCNFSM5UUEAUIA . You are receiving this because you commented.Message ID: @.***>

Dealman commented 1 year ago

image

Made some progress! Some clean up to do, and need to investigate other formats as it only currently works with Cura. I was gonna make it inside a separate python script, but I can't seem to import it whenever I try - do they have to be classes?

cameroncros commented 1 year ago

Imports in python are weird, it can take some fiddling to get it right.

I would look at how the other scripts are imported and see what they are doing.

On Sun, 27 Nov 2022, 12:05 pm Dennis, @.***> wrote:

[image: image] https://user-images.githubusercontent.com/7038067/204114641-d8047518-8576-4e1d-834a-63a9e43a0065.png

Made some progress! Some clean up to do, and need to investigate other formats as it only currently works with Cura. I was gonna make it inside a separate python script, but I can't seem to import it whenever I try - do they have to be classes?

— Reply to this email directly, view it on GitHub https://github.com/cameroncros/OctoPrint-DiscordRemote/issues/218#issuecomment-1328144670, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK7FL2SKDFS3AUFUMUP4YLWKKXUVANCNFSM5UUEAUIA . You are receiving this because you commented.Message ID: @.***>

a1co commented 1 year ago

image

Made some progress! Some clean up to do, and need to investigate other formats as it only currently works with Cura. I was gonna make it inside a separate python script, but I can't seem to import it whenever I try - do they have to be classes?

Would love to see that feature merged. Is it going to come?

Dealman commented 1 year ago

I think I have the code laying around somewhere for it, but you'd be compiling your own version of the plugin for OctoPrint. I only ever so slightly dug into making a proper PR for it but was quickly reminded of how much I despise Python so I started working on other projects instead. 😅

If I recall correctly it, if it found a thumbnail in the GCODE it used that instead of a snapshot - so it wasn't a fully implemented feature but more of a workaround.

I can't make any promises, especially not since my printer is currently out of commission and as such finding motivation to work on this feature is quite low. 😞