Can you split the gcode into 2 files so you can print in stages?
Hello,
Is it possible to the gcode for an object into 2 files and print each section by itself?
I would like to print a big piece in parts and have the MK2 automatically shutdown and start back up where it left off.
I know this can be manually done by using the pause print that is already available in the LCD menu, but wondering if it can be done automatically by having the gcode split into 2 files.
The slicer can split the object into 2 parts but then I would have to glue the two parts back into a single piece.
If I split the gcode into two files, would I just need to do the following?
- For the first half of the file, add the gcode to shut down the printer that is copied from the end of the second part of the file.
- For the second part of the file, make sure it starts at a gcode command that sets the z-axis and add the commands to heat the nozzle to the correct temp for the filament.
- Anything that I am overlooking?
Thanks for your thoughts and feedback.
David
Re: Can you split the gcode into 2 files so you can print in stages?
If the hotbed goes cold the model may detatch itself.
If the model goes cold its aparrent size may change. This could lead to poor interlayer bonding at the joint. When you start again.
Regards Joan
I try to make safe suggestions,You should understand the context and ensure you are happy that they are safe before attempting to apply my suggestions, what you do, is YOUR responsibility. Location Halifax UK
Re: Can you split the gcode into 2 files so you can print in stages?
I haven't received my MK2, but am stopping prints with a cheap i3 clone and am having success. I can't give you the exact instructions as my printer might work differently. When I receive my MK2, I'll prepare a script for this and document the process. Note I only tested this with PLA. ABS shrinks and it might cause alignment problems between the last layer of the first print and the first of the next. I also have and excellent bed adhesion using blue painters tape. My prints never pops from the bed.
This is what you need to do.
1 - determine what is the startup and end gcode for your printer
The startup gcode is identical in all your print, except for the bed and nozzle temperature. You need to check if your printer works in absolute movement and zeroes the extruder before each layer. I expect the MK2 to work in absolute mode with extruder zeroing before each layer.
Note: the ";" is the comment character in gcode. Anything after this is ignored by the printer. You can safely copy this to the actual gcode file.
Here are some startup lines that might be in your gcode files:
M107; Fan Off
M190 S60; Set Bed temperature to 60 (the S60).
M104 S210; Set nozzle temperature to 210 (the S210)
G28; Home all axis.
G21; set units to millimeters
G90; set absolute coordinates
G1 Z5; Lift nozzle to 5mm. It might have an F value next to it (feed value)
M109 S210; wait for the nozzle temperature to be reached. This is different from the M104 and the M104 that sets the temp and proceeds to the next instruction, the M109 only goes to the next instruction after the temperature has been reached.
G92 E0; sets the extruder to zero
Also check for the end gcode. But as you'll be shutting down the printer after each print, you might ignore it.
2 - determine the last layer height for the first print
This will determine where you'll split your file. For example, if you want to stop the print at 30mm (the last layer) you need to look for the following layer. I'll assume the layer height is 0.2, the next layer will be at 30.02mm:
Look for "G1 Z30.02". This instructs the z motor to move the head to 30.02mm. The line might have other commands after this, like feed rate (F).
3 - split the file
The first file will have all instructions until the line "G1 Z30.02". Then delete all the code after this. This last line will be altered.
The second file will have the initial GCode. Delete from the line that starts the real printing (probably a G1 Z0.2 or G1 Z0.3). The next lines you'll have are:
G92 E0
G1 Z30.02
4 - adjust the end of the gcode for the first file. I'll switch to relative positioning, so this code can be used in any file.
G92 E0 ; set extruder to zero (resets the counter)
M107 ; turn of the fan
M104 S0; turn off the nozzle temperature (disable the heater)
M190 E0; turn off the bed temperature (disable the heater)
G91; use relative values.
G1 Z5; move the head 5mm up. Notice this is after the G91 instruction. In this example it will move to Z35.02.
G90; now switch again to absolute coordinates
G28 X0; home the X axis
When the print ends, the head will move 5mm up and then will home on the X axis.
5 - adjust the startup code for the second file
This file starts with the usual initial gcode and then will have the following lines:
G92 E0; reset the extruder counter
G1 Z30.02; might have an F value next to it
G1 Xxx Yyyy.yy Ffffff; move the head to X,Y position with a feed rate of "ffffff".
The initial gcode has instructed the printer to heat the bed and nozzle. All that is left to do is to prime the extruder and safely position the head.
I prime the extruder by hand, so the code I'll give you is not tested (the extruder instruction).
So, before those three lines of code you need to add a copy of them to run before and make the following changes:
G92 E0; reset the extruder counter - stays the same
G1 Z31.02 E5; move to 1mm above the last printed layer to prevent bumping on it. Also extrude 5mm of filament. Copy the F value from the G1 Z30.02 instruction.
G1 Xxx Yyyy.yy Ffffff; stays the same. The nozzle will be right above the first point of the first layer.
Notice that we're moving to Z31.02, but the head is at x0 and y0. We won't hit the print. We're also extruding filament to prevent restarting the print with an empty nozzle.
After that we move to right above the starting position of the print and after that we resume the print.
The 5mm we're extruding is just a guess. As I usually prime the extruder by hand, I never bothered to set this to a correct value. If you extrude the filament by hand when the bed is finishing heating (if the head is not at the correct temperature, use the printer interface), the extruder will be primed and the 5mm will be enough.
Test this on a small print first 😉