How do I identify a layer in Gcode

Post your prints with the GCode used to help other users achieve a similar result, or get help.
Post Reply
Vic
Printmaster!
Posts: 57
Joined: Tue Mar 11, 2014 9:49 pm

How do I identify a layer in Gcode

Post by Vic » Tue Dec 23, 2014 11:33 am

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.

BenTheRighteous
Printmaster!
Posts: 695
Joined: Fri Nov 07, 2014 9:38 am

Re: How do I identify a layer in Gcode

Post by BenTheRighteous » Tue Dec 23, 2014 11:48 am

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.
nitewatchman wrote:it was much cleaner and easier than killing a chicken on top of the printer.

Vic
Printmaster!
Posts: 57
Joined: Tue Mar 11, 2014 9:49 pm

Re: How do I identify a layer in Gcode

Post by Vic » Sat Dec 27, 2014 12:47 pm

That's what I figured. I was looking for an easier way to identify it directly in the code.
Thanks for your reply

Post Reply

Return to “GCode & Test Prints”