###################################################################### # Start Print and End Print ###################################################################### # Replace the slicer's custom start and end g-code scripts with # START_PRINT and END_PRINT. [gcode_macro START_PRINT] variable_parameter_T_BED: 60 variable_parameter_T_EXTRUDER: 190 gcode: ##### Get Boundaries ##### {% set max_x = printer.toolhead.axis_maximum.x|float %} {% set max_y = printer.toolhead.axis_maximum.y|float %} {% set max_z = printer.toolhead.axis_maximum.z|float %} {% set mid_x = max_x / 2 %} {% set mid_y = max_y / 2 %} CLEAR_PAUSE G90 # Hold the hotend temperature (useful for reprints) M104 S{printer.extruder.temperature} # Start preheating the bed M117 Heating bed _LCD_KNOB COLOR=RED BLINK=1 M140 S{T_BED} # Perform a G28 'home' (if needed) SMARTHOME # Check to see if we need more time preheating the bed, if so {% if printer.heater_bed.temperature < params.T_BED|float*0.85 %} M117 Heating bed to 85% G1 X{mid_x} Y{mid_y} Z10 F6000 M106 M190 S{params.T_BED|float*0.85} {% endif %} M117 Heating bed/toolhead {% if printer.extruder.temperature < params.T_EXTRUDER|float*0.75 %} M104 S{params.T_EXTRUDER|float*0.75} {% endif %} M190 S{T_BED} M107 # Move the nozzle near the bed G1 X0.1 Y0.1 Z2.0 F6000 G1 Z0.3 F6000 M117 Heating toolhead M109 S{T_EXTRUDER} # Prime line PRIME_EXTRUDER M117 Printing [gcode_macro END_PRINT] variable_print_done: 'false' gcode: SAVE_GCODE_STATE NAME=STATE_PRINT_END ##### Get Boundaries ##### {% set max_x = printer.toolhead.axis_maximum.x|float %} {% set max_y = printer.toolhead.axis_maximum.y|float %} {% set max_z = printer.toolhead.axis_maximum.z|float %} {% set act_x = printer.toolhead.position.x|float %} {% set act_y = printer.toolhead.position.y|float %} {% set act_z = printer.toolhead.position.z|float %} ##### Calculate save move ##### {% if act_x < (max_x - 20.0) %} {% set x_safe = 20.0 %} {% else %} {% set x_safe = -20.0 %} {% endif %} {% if act_y < (max_y - 20.0) %} {% set y_safe = 20.0 %} {% else %} {% set y_safe = -20.0 %} {% endif %} {% if act_z < (max_z - 2.0) %} {% set z_safe = 2.0 %} {% else %} {% set z_safe = max_z - act_z %} {% endif %} M400 G92 E0 G1 E-2 F1800 G91 G0 Z{z_safe} F3600 G0 X{x_safe} Y{y_safe} F20000 ; move nozzle to remove stringing TURN_OFF_HEATERS M107 G90 G0 X60 Y{max_y} F18000 BED_MESH_CLEAR M300 ; Play a tone _LCD_KNOB COLOR=GREEN UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 SET_GCODE_VARIABLE MACRO=END_PRINT VARIABLE=print_done VALUE='"true"' RESTORE_GCODE_STATE NAME=STATE_PRINT_END