Detailed Layer Information

I am writing an application which will display the current job information.

I have looked at "DisplayLayerProgress" however it does not give me information about the current layer. I can get layer x of y, but

The web page has three progress bars. The bottom bar displays the progress of the current layer, ie how much of the current layer has been printed.

Is there somewhere I can get this? Obviously it is available to the web page...

1 Like

It's available on the web page as a client application that is downloading the gcode file and keeping track of position internally to that client. That exact positional data is not available from the API or socket really. There is an option in Marlin to auto report position similar to temperature, but there's still nothing built-in to OctoPrint to utilize that. A plugin could be developed to process the positional data being reported though.

Display Layer Progress only provides information about the progress of a specific layer within your job. It doesn't offer details about the current layer specifically.

Since the web page displays the current layer's progress, there must be some underlying data or API that feeds this information. Here are a few approaches you can explore to get access to it

Inspecting Network Traffic
Checking the Page Source
Contacting the API Provider

I went through the page source, read through the JavaScript, tried to follow the logic paths, and there is a call I cannot find which has the information. It probably is an Ajax call.

The API is on GitHub, and I find it difficult to winkle out contact information. Besides it would require a change to the plugin.

My last resort is to use WireShark to capture the packets.

I mean the information is getting there somehow, it's just not publicly available, ie published.

Sigh. I was hoping someone had information about a plugin which would send back JSON with the information. I can get everything else I want, just not the layer progress.

Well, WireShark it is :frowning:

Yes a plugin could be developed. However I do not do Python. Plus, I think, the information about layer progress probably requires extensive gcode parsing.

Someone has already gone through that process. I was hoping to just piggyback on the results.

The only thing that works out the current layer progress in OctoPrint is the gcode viewer. As @jneilliii mentioned, this is all done client side. Yes you're right that it requires parsing and analysing the whole gcode file. OctoPrint reports "printed bytes" over the socket, which you can match up to your analysed copy of the gcode file to work out where the current position is.

Well it appears that the Dashboard which has the required information shown is using WebSocket for data transfer.

Plus, the data is coded. Bleah.

So, since a layer is pretty much the same size as a previous layer, I will use the previous layer's duration as the MAX, then count seconds, thus giving me a completion percentage.

It's only an approximation, but better than nothing :slight_smile: