Is it possible to get the current printing layer number and the total number of layers from the OctoPrint API.
I am working on an external streaming "thing" that will display some information as text overlay. I would like some sort of progress information. From reading API docs I can see that there is a progress percentage available that is based on the gcode file size. Just wondering if layer numbers are also available.
I've not seen layers or current layer as present within this interface. An event called ZChange is fired off for layer change, which may be useful.
Within the underlying OctoPrint Python-based model appears to be currentZ which is the Z height in mm; assuming you know the layer height, you could calculate the current layer.
I want to use the total layers and current layers for a project im working on. I need to pull the values to be read by my arduino but im not sure how to do that can i do that with the octoprint API library if i have your plugin installed?
I am not sure what you mean with OP-Library.
If you use a microcontroller you need to use some kind of httpClient on your device (https://www.arduino.cc/en/Tutorial/LibraryExamples/HttpClient) and with this library you are able to send a call to your OP-Instance like this (not tested):
void loop() {
HttpClient client;
// pull data
client.addHeader("Content-Type", "application/json");
client.addHeader("X-Api-Key", "<your api key. found in settings>");
client.get("http://<ip of op instance:port>/plugin/DisplayLayerProgress/values");
..do something with the response
// sleep
If you need "realtime" data you can also use a WebSocket-Connection (no pulling, just listening), but I am not sure if there is an Arduino-lib for that feature.
I basically need the current layer and total layers as an integer to be used in the code. I don't want to get into specifics but it's a mechatronics project. I'm in my final year studying product design technology so I have just have a very basic knowledge of programming arduinos to be honest so forgive me if i'm wrong on any of the terms.
With that library i can connect to the octoprint instance but i was just wondering if it would also read your plugin or how i would go about doing that.
From my perspective the mentioned lib only use the OP-Endpoints (/api/)
and there is no support for plugin calls (/plugin/...). So you need to this by your own or reuse some methods from the lib.
Take a look into the lib-sourcecode how a op-connection could be enabled: