# Is there a way to configure printer extruder to go all way up when printing finishes in Ender 3?

With Ender 3 is there a way to configure printer extruder to go all way up when the printing finishes?

Or even with the Ultimaker Cura software?

I want this, because i'm going to put a switch on the top of the printer that will switch it off when the printer finishes (if i can make the arm with the extruder go all the way up when printing finishes.)

How can this be done?

• Have you tried adding a G0 Z(proper location) move before the end of the gcode file? – Davo Jul 18 '19 at 20:25
• @Davo no i didnt, and i never edited a gcode file, is it safe? – Nmaster88 Jul 18 '19 at 21:43
• Might not be the best idea to shut the printer off right after it finishes 3dprinting.stackexchange.com/questions/10271/… – Perplexed Dipole Jul 18 '19 at 22:03
• @Nmaster88 Yes, is safe to edit your G Code for adding code that safe your prints and your printer, also for helping to get a better adhesion and auto levels. many recommends not turn off the printer after finishing but I don't see any problem; My printers some times stops on blackouts and nothing happens. (one per month). – Fernando Baltazar Jul 19 '19 at 4:08
• @FernandoBaltazar from what you say my idea seems safe to implement. Thanks :D – Nmaster88 Jul 20 '19 at 17:18

The most safe way to move the printer up to the maximum print height is to use a concept known as "keywords" (sort of constants that are filled by the correct value when slicing) in Ultimaker Cura, certainly if you have multiple printers with different print area sizes.

To use these keywords, just add these in between curly braces and insert them into your slicer "End G-code" script. These keywords will be substituted with actual numbers from the printer settings or slicing configuration parameters. In this case we need to use the maximum print height which is specified by the keyword machine_height. This keyword takes its value from the printer settings, set for the printer in the graphical user interface of the printer settings, see image below (this is a configuration of an Ultimaker 3 Extended, it also shows the Start G-code and End G-code which you can tweak yourself, as seen by the additional G-code line G0 F10000 Z{machine_height} that has been added for this demonstration).

E.g. similar to this answer, you could solve this with a keyword. Now when you slice for a certain printer (e.g. with the printer settings of the image above), the correct value will be filled in automatically when slicing the print object as can be seen from this snippet of G-code:

...
G91 ;Relative movement
G0 F15000 X8.0 Z0.5 E-4.5 ;Wiping+material retraction
G0 F10000 Z1.5 E4.5 ;Compensation for the retraction
G90 ;Disable relative movement
G0 F10000 Z300 ; <------------ note to see {machine_height} be resolved to 300 mm
...


This is specifically for Ultimaker Cura. Do note that e.g. Slic3r even takes the keyword concept further by allowing arithmetic and logic, similar as you could do in programming languages!

In Ultimaker Cura (and pretty much any slicer), you can easily modify the end code of the Ender 3. To go all the way up, you could add the following in the end:

G90 ;absolute positioning
G1 Z300 ;goto height 300 ; Move to 300 mm = 30 cm.
G91 ;back to relative positioning


If you use OctoPrint, there is a plugin that will allow you to take action on certain events, such as print completion. The action that it can take would allow you to turn of a TP-link smart plug; which would turn off the printer. You could then use the phone app to turn it back on.

• while you could turn off the printer that way, it does not answer the question OP asks: how to get the gantry to top out after a print – Trish Jul 19 '19 at 6:52
• "I want this, because i'm going to put a switch on the top of the printer that will switch it off when the printer finishes" - This is the OP's objective. – user77232 Jul 19 '19 at 14:21
• they might have other reasons why they want a mechanical switch. – Trish Jul 19 '19 at 17:08