<p>I just completed my first print on my Ender-3 and when the print finalized itself the nozzle didn't elevate itself to clear away from the piece. I watched as the nozzle slowly lowered itself into my print and destroy it. Here is the gcode generated by Slic3r used:</p>

<pre>
; Filament-specific end gcode
G4 ; wait
M221 S100
M106 S0 ; turn off cooling fan
M104 S0 ; turn off extruder
M140 S0 ; turn off bed
G91
G1 F1800 E-3
G90
G1 Z{z_offset+min(layer_z+30, max_print_height)}{endif} ; Move print head up
G28 X0 ; home x and y axis
G1 Y180; Remove Print Position
M84 ; disable motors
M300 S2600 P100; Beep
; filament used = 24040.5mm (57.8cm3)
; total filament cost = 0.0
</pre>

<p><a href="https://i.stack.imgur.com/mZncw.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/mZncw.jpg" alt="preview of the destruction"></a></p>

[{'answer_id': 8141, 'author': 'Trish', 'author_id': 8884, 'author_profile': 'https://3dprinting.stackexchange.com/users/8884', 'pm_score': 1, 'selected': False, 'text': "<p>Your print end code should have read something akin to this:</p>\n\n<pre><code>; Filament sy end gcode\nG4 ; wait\nM221 S100\nM106 S0 ; turn off cooling fan\nM104 S0 ; turn off extruder\nM140 S0 ; turn off bed\n\n; End code\nG1 F1800 E-3 ; retract 3 mm\nG1 Z30 ; Move print head up 30mm\nG28 X0 ; home x and y axis\nM84 ; disable motors\nM300 S2600 P100; Beep\n</code></pre>\n\n<p>The problem with your end code is the <code>G90</code> for <strong>absolute</strong> measurements together with the formula <code>G1 Z{z_offset+min(layer_z+30, max_print_height)}{endif}</code> to set the height. The printer itself doesn't calculate anything. That what it doesn't interpret, it ignores, interpreting that whole thing as something crazy like <code>G1 Z30</code> to force the printer to go to Absolute 30\xa0mm above absolute 0. To fix it,  your slicer would need to calculate <code>{z_offset+min(layer_z+30, max_print_height)}</code> for the printer - which seems to come out to 30mm above the print and then an if-statement that is not started anywhere.</p>\n\n<p>Going up 30\xa0mm can be much easier be done by staying in <code>G91 ; relative measurements</code> and calling <code>G1 Z30</code> to go up another 30\xa0mm, though this might be too high for the printer frame.</p>\n"}, {'answer_id': 8150, 'author': '0scar', 'author_id': 5740, 'author_profile': 'https://3dprinting.stackexchange.com/users/5740', 'pm_score': 4, 'selected': True, 'text': '<p>You are using <strong>incorrect commands</strong> in your end-code for the <strong>incorrect tool</strong> with respect to the print head raise.</p>\n\n<p>Slic3r has no knowledge of the maximum printer height (as in variable <code>max_print_height</code>) because there is <strong>no input field to specify this</strong>, as can be seen in this partial screenshot:</p>\n\n<p><a href="https://i.stack.imgur.com/qPz1z.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qPz1z.png" alt="Slic3r print area settings"></a></p>\n\n<p>However, in Slic3r PE (Prusa Edition), there is a possibility to enter such a value, as seen in the following partial screenshot:</p>\n\n<p><a href="https://i.stack.imgur.com/lCHxV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lCHxV.png" alt="Slic3r PE print volume settings"></a></p>\n\n<p>Note that in both editions, the <code>Bed shape</code> interface is equivalent when <code>Set...</code> is pressed:\n<a href="https://i.stack.imgur.com/jTLBm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jTLBm.png" alt="Slic3r and Slic3r PE bed area settings"></a></p>\n\n<p>To use the raising of the head, respecting the maximum print height, in <strong>Slic3r PE</strong>, you need to add the following line:</p>\n\n<pre><code>{if layer_z &lt; max_print_height}G1 Z{z_offset+min(layer_z+60, max_print_height)}{endif}\n</code></pre>\n\n<p>This will parse fine in <strong>Slic3r PE</strong>, but not in <strong>Slic3r</strong> (as <code>max_print_height</code> is not known).</p>\n\n<p>If you want such a command in <strong>Slic3r</strong>, you need to enter (for a printer with a maximum print height of 240&nbsp;mm):</p>\n\n<pre><code>G1 Z{[z_offset]+min([layer_z]+3, 240)}\n</code></pre>\n\n<p>results in Slic3r for a 20x20x20&nbsp;mm calibration cube with a zero <code>z_offset</code> to:</p>\n\n<pre><code>G1 Z23\n</code></pre>\n'}, {'answer_id': 11241, 'author': 'PikesPeakCode', 'author_id': 6646, 'author_profile': 'https://3dprinting.stackexchange.com/users/6646', 'pm_score': 1, 'selected': False, 'text': "<p>The same thing happened to me several years ago. My print was a fairly tall part for my delta printer, about 220 mm. In many previous prints, the print head would always go up after finishing, but what I didn't know was that the Slic3r finish print routine specified an absolute Z height of about 200 mm. When the tall part finished, the still-hot print head moved down and ruined the top of the print. </p>\n\n<p>After figuring out that the routine had an absolute reference, I replaced it with a relative movement 20 mm up. It's worked fine since then. An easy fix.</p>\n"}]
['https://3dprinting.stackexchange.com/questions/8139', 'https://3dprinting.stackexchange.com', 'https://3dprinting.stackexchange.com/users/14425/']