# How to configure Cura to run the Z probe before heating

I'm using Cura as my slicing/printing software and I just started using the BuildTak printing surface.

The BuildTak is damaged by pushing a hot nozzle into it and my printer's (Robo3D R1+) autoleveling feature works by pushing the nozzle into the build surface.

Is there a way to configure Cura so that it runs the Z probe first, then heat up the nozzle?

My first sheet of BuildTak already has 10 small holes in it (at the homing position and at the 9 leveling touch points)

In Cura (and Slic3r), you can 100% customize what the printer does before printing your actual model through custom start/end g-code.

If you navigate to the Start/End-GCode tab in Cura, then select start.gcode, you can see what operations are run before each print begins. Lines prefixed with ; are comments, and does not affect the printing in any way.

Basically, we want to manually tell the printer to do the auto leveling before heating up the nozzle by editing the g-code in start.gcode.

### G-Code generated with the default start.gcode:

If you try to slice some model with the default code found in start.gcode, you will get something like the following (depending on your printer):

; CURA AUTOMATICALLY INSERTS THESE TEMPERATURE CODES

M190 S70.000000 ; Set bed temperature to 70 degrees
M109 S210.000000 ; Set nozzle temperature to 210 degrees

; THESE ARE THE CODES FROM START.GCODE (for a ROBO 3D R1)

G28          ;move printer to endstops (the home position)
G92 E0       ;zero the extruded filament length
M565 Z-1     ;set z-probe offset
G1 Z5 F5000  ;move the printer 5mm above the bed
G29          ;run auto-leveling

; THE ACTUAL MODEL BEGINS HERE

;Layer count: 168
;LAYER:0
.
.


### Analyzing the g-code output

At the top of this code snippet, we can see that Cura automatically inserts g-code for heating up the bed and nozzle to their respective temperatures with the M190 and M109 g-codes. This means the printer always will heat up the nozzle before reading the start.gcodes that we set. However, if we manually override M109 code in start.gcode, the M109 at the top will automagically disappear from the generated g-code output! (Thanks, @TomvanderZanden!)

We could therefore use the auto-leveling command G29 before manually setting the nozzle temperature with M109; specifically, we want to add M109 S{print_temperature}, which reads the Basic -> Print Temperature-setting in Cura, and replace {print_temperature} with it automatically.

### Manipulating start.gcode:

In order to postpone heating the hotend till after probing, start.gcode could be something like:

G28          ;move printer to endstops (the home position)
G92 E0       ;zero the extruded filament length
M565 Z-1     ;set z-probe offset     <-----   ( YOU HAVE TO ADJUST THIS, READ BELOW)
G1 Z5 F5000  ;move the printer 5mm above the bed
G29          ;run auto-leveling
M109 S{print_temperature}    ;set nozzle temperature, and wait for it heat up


And that's about it! You can then use these codes in your start.gcode. However, you probably will have to recalibrate your z-prove offset.

Normally, auto-leveling is done with the nozzle heated for a reason: when the nozzle is warm, it expands slightly, moving closer to the bed. You might therefore have to adjust your Z-probe offset with the M565 command (as demonstrated in the snippet) to account for the increase in nozzle length when warm.

### Remember:

Remember that when editing g-code in this manner, you will take full control of how the printer operates. You could therefore very well do something unintended, so keep the power switch close!

• This answer misses a very important point: in Cura (and something similar works for Slic3r and Simplify3D) you can insert "M109 S{print_temperature}" into your G-code. It will replace {print_temperature} with the set printing temperature and not add its own M109. This way you don't need to do the ugly hack of setting the temp to 0. Feb 3, 2016 at 22:49
• @TomvanderZanden, you are entirely right! I didn't think that Cura would be smart enough to remove the first M109 if you set it manually in start.gcode, but it seems like it is! I will update the answer. Feb 4, 2016 at 6:10
• {print_temperature} didn't work for me. {material_print_temperature} did. Look here for more. Sep 3, 2017 at 20:25

As pointed out in Markus's comment to Tormod's answer, {print_temperature} needs to be replaced by {material_print_temperature}, so the code now becomes:

G28          ;move printer to endstops (the home position)
G92 E0       ;zero the extruded filament length
M565 Z-1     ;set z-probe offset     <-----   ( YOU HAVE TO ADJUST THIS, READ BELOW)
G1 Z5 F5000  ;move the printer 5mm above the bed
G29          ;run auto-leveling
M109 S{material_print_temperature}    ;set nozzle temperature, and wait for it heat up