Cura adds code BEFORE the printer's Start Gcode?

I’m working to solve a few issues that I’m running into when printing small, precision parts. In working to resolve part lift with PETG, I’ve added the G29 code to the end of my Start Code section in Cura (Sovol’s version and the general 5.2.1 latest from Ultimaker). However, I’ve discovered that Cura is adding code BEFORE the Stat Gcode entry. This is resulting in my bed and extruder heating to temp (75 and 235) and then cooling back down to 60 and 120 when the G29 autolevel command is executed. It then tries to start the print at those lower temps.

Here’s the result of a slice

;FLAVOR:Marlin
;TIME:1161
;Filament used: 0.836139m
;Layer height: 0.15
;MINX:21.8
;MINY:21.8
;MINZ:0.3
;MAXX:208.2
;MAXY:208.2
;MAXZ:0.75
;Generated with Cura_SteamEngine 5.2.1
M140 S70
M105
M190 S70
M104 S210
M105
M109 S210
M82 ;absolute extrusion mode
M201 X500.00 Y500.00 Z100.00 E5000.00 ;Setup machine max acceleration
M203 X500.00 Y500.00 Z10.00 E50.00 ;Setup machine max feedrate
M204 P500.00 R1000.00 T500.00 ;Setup Print/Retract/Travel acceleration
M205 X8.00 Y8.00 Z0.40 E5.00 ;Setup Jerk
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate

G28 ;Home
G28 ;Level bed

G92 E0 ;Reset Extruder
G1 Z2.0 F3000 ;Move Z Axis up
G1 X10.1 Y20 Z0.28 F5000.0 ;Move to start position
G1 X10.1 Y200.0 Z0.28 F1500.0 E15 ;Draw the first line
G1 X10.4 Y200.0 Z0.28 F5000.0 ;Move to side a little
G1 X10.4 Y20 Z0.28 F1500.0 E30 ;Draw the second line
G92 E0 ;Reset Extruder
G1 Z2.0 F3000 ;Move Z Axis up

Is it normal for Cura to perform the bed and extruder temp settings (M140, M104) before the Start Gcode section? Is there any way to change that?

Thanks,
Tim

I believe cura looks for temperature variables in the start Gcode and, if not present, will insert the commands to set them. So you could add

M104 S{material_print_temperature}
M140 S{material_bed_temperature}

And that should stop cura from adding additional code.

Add it to the top of the Start Gcode section?

I don’t think it matters where in the start gcode, but in mine, the temperature commands are usually in the first few lines.

Cura settings are stored in a subfolder named “definitions”. There are several json files that define each print mode and a file named “fdmprinter,def,json” for common settings. It is very likely that you’ll be able to apply the desired changes here.
More details could be found here: https://github.com/Ultimaker/Cura/wiki/Definition-Files-Explained

Please post your start gcode.

Here’s what I came up with:

M201 X500.00 Y500.00 Z100.00 E5000.00 ;Setup machine max acceleration
M203 X500.00 Y5`00.00 Z10.00 E50.00 ;Setup machine max feedrate
M204 P500.00 R1000.00 T500.00 ;Setup Print/Retract/Travel acceleration
M205 X8.00 Y8.00 Z0.40 E5.00 ;Setup Jerk
M220 S100 ;Reset Feedrate
M221 S100 ;Reset Flowrate

G28 ; Home
G29 ; Bed Level

M104 S{material_print_temperature}
M105
M109 S{material_print_temperature}
M140 S{material_bed_temperature}
M105
M190 S{material_bed_temperature}

G92 E0 ;Reset Extruder
G1 Z2.0 F3000 ;Move Z Axis up
G1 X10.1 Y20 Z0.28 F5000.0 ;Move to start position
G1 X10.1 Y200.0 Z0.28 F1500.0 E15 ;Draw the first line
G1 X10.4 Y200.0 Z0.28 F5000.0 ;Move to side a little
G1 X10.4 Y20 Z0.28 F1500.0 E30 ;Draw the second line
G92 E0 ;Reset Extruder
G1 Z2.0 F3000 ;Move Z Axis up

That sorted it.

Tim