Starting and Ending G-Code

Cura

Example of Starting G-Code for Cura:

G21 ; metric values
G90 ; absolute positioning
M82 ; set extruder to absolute mode
M107 ; start with the fan off
M140 S{material_bed_temperature_layer_0} ; Set bed temperature (no wait)
G28 X Y F6000 ; move X/Y to min endstops
G28 Z F1200 ; move Z to min endstops ; raise the nozzle
G28 X Y F6000 ; move X/Y to min endstops
M190 S{material_bed_temperature_layer_0} ; wait for bed temperature to reach target
M104 S{material_print_temperature_layer_0} T0 ; set extruder temperature (no wait)
G29 ; auto-leveling
G28 X Y F6000 ; move X/Y to min endstops, may disable bed leveling
M420 S1 ; enable bed leveling compensation
M109 S{material_print_temperature_layer_0} T0 ; set extruder temperature and wait
M300 P200 ; beep to indicate that the temp is reached
G1 Z15 F1200 ; raise to have room
G92 E0 ; zero the extruded length
G1 F140 E30 ; extrude 3mm of feed stock
G4 S2 ; Wait for 2 seconds
G92 E0 ; zero the extruded length
M117 Printing from Cura...; message

Example of Ending G-Code for Cura:

M104 S0 ; extruder heater off
M140 S0 ; heated bed heater off
M107; Turn fan off
G91 ; relative positioning
G1 E-1 F300 ; retract the filament a bit before lifting the nozzle to release some of the pressure
G1 Z+2.0 E-5 F6000 ; move Z up and retract filament even more
G90 ; absolute positioning
G1 X0 F6000 ; move X to min endstops so the head is out of the way
G1 Y160 F6000 ; move the bed so it is easy to access to the printed part
G92 E0 ; zero the extruded length
M84 ; steppers off

Simplify3D

Example of Starting G-Code for Simplify3D:

G21 ; metric values
G90 ; absolute positioning
M82 ; set extruder to absolute mode
M107 ; start with the fan off
M140 S[bed0_temperature] ; Set bed temperature (no wait)
G28 X Y F6000 ; move X/Y to min endstops
G28 Z F1200 ; move Z to min endstops ; raise the nozzle
G28 X Y F6000 ; move X/Y to min endstops
M190 S[bed0_temperature] ; wait for bed temperature to reach target
M104 S[extruder0_temperature] T0 ; set extruder temperature (no wait)
G29 ; auto-leveling
G28 X Y F6000 ; move X/Y to min endstops
 may disable bed leveling
M420 S1 ; enable bed leveling compensation
M109 S[extruder0_temperature] T0 ; set extruder temperature and wait
M300 P200 ; beep to indicate that the temp is reached
G1 Z15 F1200 ; raise to have room
G92 E0 ; zero the extruded length
G1 F140 E30 ; extrude 3mm of feed stock
G4 S2 ; Wait for 2 seconds
G92 E0 ; zero the extruded length
G1 X5 Y5 F2000; Move a little over the bed
M117 Printing from Simplify3D...; message

Example of Ending G-Code for Simplify3D:

M104 S0 ; extruder heater off
M140 S0 ; heated bed heater off
M107; Turn fan off
G91 ; relative positioning
G1 E-1 F300 ; retract the filament a bit before lifting the nozzle to release some of the pressure
G1 Z+2.0 E-5 F6000 ; move Z up and retract filament even more
G90 ; absolute positioning
G1 X0 F6000 ; move X to min endstops so the head is out of the way
G1 Y160 F6000 ; move the bed so it is easy to access to the printed part
G92 E0 ; zero the extruded length
M84 ; steppers off

Do you have a start and ending G-Code for PrusaSlicer 2.1 or would one of the choices above work?
Thanks

No, I don’t have and the G-Code above needs probably some adaptations.

I’ve found this to work for me. It has auto levelling and a purge line at the start which I find helps clear the nozzle really well.
Start G Code:

G21 ; metric values
G90 ; absolute positioning
M82 ; set extruder to absolute mode
M107 ; start with the fan off
M140 S[first_layer_bed_temperature] ; Set bed temperature (no wait)
G28 X F6000 ; move X/Y to min endstops
G28 Y F6000 ; move X/Y to min endstops
G28 Z F1200 ; move Z to min endstops ; raise the nozzle
G28 X Y F6000 ; move X/Y to min endstops
M190 S[first_layer_bed_temperature] ; wait for bed temperature to reach target
M104 S[first_layer_temperature] ; set extruder temperature (no wait)
M400 ; wait until previous lines finished
G29 ; auto-leveling
G28 X Y F6000 ; move X/Y to min endstops, may disable bed leveling
M420 S1 ; enable bed leveling compensation
G1 Z25 F1000 ; raise extruider to prevent buildup
M109 S[first_layer_temperature] ; set extruder temperature and wait
M300 P200 ; beep to indicate that the temp is reached
G1 Y-3.0 Z10.0 F1000.0 ; move out of print volume and raises nozzle to avoid clips
G1 X45 F1000.0 ; go to purge line start position
G1 Z0.3 F700 ; lower extruder to begin purge line
G1 X85.0 E9 F500.0 ; start purge
G1 X125 E12.5 F500.0 ; finish purge line
G92 E0 ; zero the extruded length
M117 Printing from PrusaSlicer...; message

End G Code:

M400 ; wait until previous lines finished
M104 S0 ; extruder heater off
M140 S0 ; heated bed heater off
M107; Turn fan off
G91 ; relative positioning
G1 E-0.5 F300 ; retract the filament a bit before lifting the nozzle to release some of the pressure
G1 Z+2.0  F6000 ; move Z up and retract filament even more
G90 ; absolute positioning
G1 X0 F6000 ; move X to min endstops so the head is out of the way
G1 Y160 F6000 ; move the bed so it is easy to access to the printed part
G92 E0 ; zero the extruded length
M84 ; steppers off