Hello Everyone,
I am looking to add a custom G-code to my printer settings to keep the first layer temperature same for the first 3 layers. From what I was looking there is no setting for this by default.
I have been using Placeholder List and Marlin Docs as a reference, but I am unable to get the syntax correct for it to execute my request.
Questions:
- Can someone assist me with correcting my syntax?
- Should the custom G-Code go in Printer settings>Machine gcode>Template Custom G-code?
Syntax:
{if layer_num < 4} M104 S{nozzle_temperature_initial_layer[current_extruder]} ; Set nozzle temperature for first 3 layers
{endif}
Thank you in advance!
Welcome to the forum.
While this makes sense from a programing perspective that “Loops” code, in 3d printer gcode the program is only run once, top to bottom. It doesn’t have the ability to use canned cycles that loop back. If you go the conditional statement route you will need to insert it on every layer.
I think I would try inserting it at the bottom of the “Layer change” gcode.
Here is another “simpler” option.
The slicer only has provisions to have a different initial layer temp.
How I suggest you approach this is to change the “Initial” and “Other” layer temps in the filament settings to what you want the first 3 layers to be.
Then simply use the slicer to insert a "M104 S(Whatever temp you want for the subsequent layers) at the beginning of the 4th layers.

2 Likes
Thank you JonRaymond! Appreciate the help!
Not sure how I’ve missed the layer change G-code, that is perfect.
The second method is definitely easier for 1 off prints where this is needed. Basically, I print a lot of flat lamps and the first method will work for me because it is “set it and forget it”.
Will add the exact syntax once I finish testing it.
1 Like