<p>As pointed out in <a href="https://3dprinting.stackexchange.com/questions/454/how-to-configure-cura-to-run-the-z-probe-before-heating/469#comment6403_469">Markus's comment</a> to <a href="https://3dprinting.stackexchange.com/a/469/4762">Tormod's answer</a>, <code>{print_temperature}</code> needs to be replaced by <code>{material_print_temperature}</code>, so the code now becomes:</p>
<pre><code>G28          ;move printer to endstops (the home position)
G92 E0       ;zero the extruded filament length
M565 Z-1     ;set z-probe offset     &lt;-----   ( 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
</code></pre>

CC BY-SA 4.0
2021-12-30T05:29:54.163Z
2021-12-30T05:29:54.163Z
Greenonline
<p>In Cura (and Slic3r), you can 100% customize what the printer does before printing your actual model through custom <strong>start/end g-code</strong>.</p>

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

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

<h3>G-Code generated with the default start.gcode:</h3>

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

<pre><code>; 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
.
.
</code></pre>

<h3>Analyzing the g-code output</h3>

<p>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 <a href="http://reprap.org/wiki/G-code#M190:_Wait_for_bed_temperature_to_reach_target_temp" rel="noreferrer">M190</a> and <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a> g-codes. This means the printer always will heat up the nozzle before reading the <code>start.gcode</code>s that we set. However, if we manually override <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a> code in <code>start.gcode</code>, the <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a> at the top will automagically disappear from the generated g-code output! (Thanks, @TomvanderZanden!)</p>

<p>We could therefore use the auto-leveling command <a href="http://reprap.org/wiki/G-code#G29:_Detailed_Z-Probe" rel="noreferrer">G29</a> before manually setting the nozzle temperature with <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait" rel="noreferrer">M109</a>; specifically, we want to add <code>M109 S{print_temperature}</code>, which reads the <code>Basic -&gt; Print Temperature</code>-setting in Cura, and replace <code>{print_temperature}</code> with it automatically.</p>

<h3>Manipulating start.gcode:</h3>

<p>In order to postpone heating the hotend till after probing, <code>start.gcode</code> could be something like: </p>

<pre><code>G28          ;move printer to endstops (the home position)
G92 E0       ;zero the extruded filament length
M565 Z-1     ;set z-probe offset     &lt;-----   ( 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
</code></pre>

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

<h3>Adjust z-probe offset:</h3>

<p>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 <a href="http://reprap.org/wiki/G-code#M565:_Set_Z_probe_offset" rel="noreferrer">M565</a> command (as demonstrated in the snippet) to account for the increase in nozzle length when warm.</p>

<h3>Remember:</h3>

<p>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! </p>

CC BY-SA 3.0
2016-02-03T22:49:16.473Z
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.
Tom van der Zanden
CC BY-SA 3.0
2016-02-04T06:10:23.070Z
@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.
Tormod Haugene
CC BY-SA 3.0
2017-09-03T20:25:27.103Z
`{print_temperature}` didn't work for me. `{material_print_temperature}` did. [Look here for more.](https://ultimaker.com/en/community/49978-changing-cura-generated-start-code)
Markus Hütter
CC BY-SA 3.0
2016-02-03T19:08:20.430Z
2016-02-04T06:20:01.963Z
2016-02-04T06:20:01.963Z
Tormod Haugene
<p>I'm using Cura as my slicing/printing software and I just started using the BuildTak printing surface.</p>

<p>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.</p>

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

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

<software><ultimaker-cura><slicing><calibration><z-probe>
How to configure Cura to run the Z probe before heating
Nir
# How to configure Cura to run the Z probe before heating

(Asked by: username_0 on 2016-02-03)

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)

**Tags:** software, ultimaker-cura, slicing, calibration, z-probe


---

## 2 answers

### Answer by username_2 on 2016-02-03. Score: 10 | Accepted answer

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](http://reprap.org/wiki/G-code#M190:_Wait_for_bed_temperature_to_reach_target_temp) and [M109](http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait) g-codes. This means the printer always will heat up the nozzle before reading the `start.gcode`s that we set. However, if we manually override [M109](http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait) code in `start.gcode`, the [M109](http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait) at the top will automagically disappear from the generated g-code output! (Thanks, @username_3!)

We could therefore use the auto-leveling command [G29](http://reprap.org/wiki/G-code#G29:_Detailed_Z-Probe) before manually setting the nozzle temperature with [M109](http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait); 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.

### Adjust z-probe 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](http://reprap.org/wiki/G-code#M565:_Set_Z_probe_offset) 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!

> **Comments:**
> **username_3**: 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.  
> **username_2**: @username_3, 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.  
> **username_4**: `{print_temperature}` didn't work for me. `{material_print_temperature}` did. [Look here for more.](https://ultimaker.com/en/community/49978-changing-cura-generated-start-code)  

---

### Answer by username_1 on 2021-12-30. Score: 0

As pointed out in [username_4's comment](https://3dprinting.stackexchange.com/questions/454/how-to-configure-cura-to-run-the-z-probe-before-heating/469#comment6403_469) to [username_2's answer](https://3dprinting.stackexchange.com/a/469/4762), `{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

```


---

