Octoprint metadata analysis code extraction - analyze GCODE server-side myself?

Hey there. I'm working on a service that works with Octoprint, and currently rely on it to analyze the gcode file for print dimensions and filament usage. This process is often very slow though, so I was wondering if it could be possible to use the Octoprint metadata analysis code on my server instead, and whether or not that'd improve the while thing time-wise?

I'm not an GCODE expert, so I don't wanna throw myself into writing a custom analyser, but I also don't wanna go through too much trouble with trying to "extract" the Octoprint one, if it relies too heavily on a lot of other Octoprint components and classes from other parts of Octoprint...

Do you guys think it's something I should try to do? Or are there some open sourced gcode analysis libraries out there that I'm just missing, that would be better to use?

Just an idea I had that I'm now looking for a little bit of feedback on, from people who know more about Octoprint than me :slight_smile:

I found "http://gcode.ws/" which looks pretty cool - anyone got experience with this?

You may want to check out this.

1 Like

Hi @AlbertMN,

IMHO before I start developing new stuff I looked around for such a ready to use solution, like you do.
BUT in this case I would like to ask some questions:

  • When do you need such information? After upload, file selection, after print?
  • What is "slow" in your case? 2 seconds, 5 minutes, ... Maybe the performance could be increased by upgrading your raspi (if you use one)
  • How is your "system-landscape", look a like? E.g. gcode.ws is executed on the clients browser, octoprint analyse the gcode on the python server side.

So, to give you a good answer we need more informations :slight_smile:

Another plugin example would be print time genius. It uses an external processor that is more efficient and I believe it calculates print size and such.

@jneilliii I should've specified; I was looking for a GCODE-analyzer for the data like filament usage, estimated print time and max- min coordinates for the code. I needed this data to see if the model would fit the 3D-printer's bed, and to check if the printer has enough filament to finish the print. I used OctoPrint to analyze the file before, but for the analysis to finish, it could take up to 6 minutes...

I ended up tearing gcode.ws apart, and stripped it of all the visuals I didn't need. Ended up with a result that was fine; a client-side GCODE analysis. A server-side analysis would've been just fine as well, but by the looks of it I would've had to code it from the ground up, which I was not really up to.

It took about 6 hours to modify the code to fit my needs, but I now have a much faster analysis of GCODE! :smiley: The file that took our poor Raspberries (3B) ~6 minutes to analyze now takes about 10 seconds (it's the second file I upload in the gif, the one that isn't basically instant).

The PrettyGcode viewer looks super cool as well, and I can definitely get some use out of that - but I ended up with what I wanted to!

The gif above shows the live analysis of the GCODE-files I upload. One file that is all good - printer has enough filament and it fits the bed, the second GCODE is much larger, takes some moer time to analyze, and doesn't fit the bed.

Thanks for your comments!