Page 1 of 1

How do I identify a layer in Gcode

Posted: Tue Dec 23, 2014 11:33 am
by Vic
This is probably an easy question for most of you. I use Slic3r and usually have pretty good luck with it and am used to it. I would like to know an easy way to identify what gcode corresponds to a specific layer in the print. For example if my model has 100 layers I would like to be able to insert a pause code at say layer 50 to change filament.

I am sorry if this has been asked and answered. I tried searching it in the forum but I couldn't find the answer.

Re: How do I identify a layer in Gcode

Posted: Tue Dec 23, 2014 11:48 am
by BenTheRighteous
Well it depends on the slicer that you use I'm sure. I use MatterSlice and I see lines like this in the gcode:

; LAYER:5
G0 F12000 X-31.95 Y60.98 Z1.20

so that makes it super easy but really you would look for anything with a Z coordinate. For the line I posted, the Z was 1.20. I was printing with a 0.2 layer height, so the formula would be ((z coordinate - starting layer height) / layer height) = current layer.

Since my starting layer height is no different than my regular layer height, my math would work out to be (1.2 - 0.2) / 0.2 = 5th layer.

Re: How do I identify a layer in Gcode

Posted: Sat Dec 27, 2014 12:47 pm
by Vic
That's what I figured. I was looking for an easier way to identify it directly in the code.
Thanks for your reply