We’ve all experienced it at some point. Your prints just randomly stopping, your extruder getting clogged mid way, or anything else, the result is the same: when you come back to your printer all you see is half a print.

This happened to me this morning so I decided to make a quick post on how to make the best of the situation.

Step one

  • Measure the height your print managed to achieve.

The height measured was 44.2mm, in this case I am using a layer height of .32mm with a first layer height of also .32mm.

  • Subtract the first layer height from the total height, then divide the answer by your normal layer height

(44.2 - 0.32)/0.32=137.125

Of course, this value needs to be a whole number, and is a result of the tolerance of our measurement. this is why we did this calculation!

  • round the answer down to the nearest number

in this case 137. (This is (+1) is the number of layers)

  • multiply that by the layer height, add the first layer height

(137*0.32)+0.32=44.16. This is the height achieved, as far as the Gcode is concerned.

Step two

Edit your Gcode. In this case, I am using RepetierHost, but you may use any program to edit your code.

  • Search for the line of code indicating the Z-value. Add a Z before the calculated height

In my case, I need to search for Z44.16


  • click to select the end of the previous line of code


  • Then scroll up and, while pressing shift, click on the end of your start Gcode (all the descriptive code)

  • Delete the selection. You are now left with what you need to continue printing. Save it.

Step three

Start your printer with the saved Gcode file. Finish your print.

I tend to only use this for things I print for myself, nothing for clients, as there is usually a noticeable seam where the print failed. Anyway, I hope this will be of help as I keep seeing failed prints.

Happy printing!


Oh man! This is amazing content. Thank you for sharing this with us - it’s super useful




Nice trick and good explanation. I’m printing the same files at this moment, the ‘Poppy’ robot.


Nice one, Thought this was not possible.

Heroooo!!! :slight_smile:


Excellent post, thanks!

I started doing this a few months ago on my Makerbot when I switched to Simplify 3d and it’s has saved my sanity on a few occasions. One thing that I found on my machine that I would add… I have to edit the start-up procedure for my printer so that there is a pause between the x,y,z homing, and the Z axis moving to it’s extent. If I don put a 10 second pause in there, the carriage moves to the start position before the piece is clear of the head.

Thanks for the measuring procedure! very helpful.

My approach is slightly easier I think.

When your print stops give the command M114.

This gives your exact z- height.

Look for this number in the g- code.

When you found it delete everything before this.

Load the code and start printing.

Thanks a lot.

I wrote a python utility for doing this. You just have to load the output.gcode file back into repetier.

@TURush3D that’s simply amazing, thanks so much! I’m trying right now to edit the gcode of a failed print

1 Like

Can I ask you a question? Until where I have to delete the code? Because the first lines are different from the rest of the program body.

1 Like

This is a wonderful information. My problem is The power went of and my UPS also failed. I removed the model from the bed out of frustration. I want to build remaining part and stick the 2 to have the complete model. It was 5 hrs job. Any suggestion please

Thank you very much.

In return i would share my experience due to suddenly disconnected (Not sure the issue).

I,m using repetier with Curaengine slicer. During my exploration to find the z-axis i,ve found that at ‘Printer’ tab, ‘Job Status’ you can see last line ‘Total Line’ where the printer stopped. From there you know where to start and remove all previous line and start printing.

Just for precaution, standby to immediately stop before the nozzle crash onto your model and re-adjust your pre-setting. For me, I need to relocate manually the nozzle at X & Y axis before it goes down (homing Z, refer below). Attached the pre-setting for example. Change if required.

M106 S0 ;make sure fan is off
M18 ;turn off motors
G28 Z0 ;homing Z
G1 Z105 F18000 ;move nozzle up
M18 ;turn off motors
G28 X0 Y0 ;homing X/Y
G1 X115 Y300 F2000 ;move heated bed forward for easy access to clean
M190 S60 ; set bed temp & wait
M109 S230 ; set extruder temp & wait
G1 X115 Y150 F2000 ;move extruder to the center

Hopefully it might help others. Sorry for my English.

You can use this box, it automatic cut the gcode file and go back to you Z position and print.

I use to cut and restart unfinished cnc jobs a lot when working as a machinist. the only difference here is having to know how to get the layer height it left off on.
i tried this and i had a problem with one dimension being off about 1mm. i only had 5 layers left…
so results may vary. its also good to know my printers repeatability on the Y axis sucks.
I’ll have to get better switches for the endstops.