Skip to content

Instantly share code, notes, and snippets.

@just-trey
Last active November 6, 2023 05:53
Show Gist options
  • Save just-trey/040c43367b4f42588b48b68af886ec55 to your computer and use it in GitHub Desktop.
Save just-trey/040c43367b4f42588b48b68af886ec55 to your computer and use it in GitHub Desktop.
simple start / end print macro
M104 S0 ; Stops PrusaSlicer from sending temp waits separately
M140 S0
print_start EXTRUDER=[first_layer_temperature[initial_extruder]] BED=[first_layer_bed_temperature]
print_start EXTRUDER={material_print_temperature_layer_0} BED={material_bed_temperature_layer_0}
#####################################################################
# print_start macro
#####################################################################
[gcode_macro PRINT_START]
gcode:
# This part fetches data from your slicer. Such as bed temp, extruder temp, chamber temp and size of your printer.
{% set target_bed = params.BED|int %}
{% set target_extruder = params.EXTRUDER|int %}
{% set x_wait = printer.toolhead.axis_maximum.x|float / 2 %}
{% set y_wait = printer.toolhead.axis_maximum.y|float / 2 %} # This is not used but is the ycenter of the bed
SET_DISPLAY_TEXT MSG="Homing" # Displays info
G28 # Full home (XYZ)
G90 # Use absolute positioning
BED_MESH_CLEAR # Clears old saved bed mesh (if any)
SET_DISPLAY_TEXT MSG="Hotend: 150c" # Displays info
M104 S150 # Heats the nozzle to 150c
SET_DISPLAY_TEXT MSG="Bed: {target_bed}c" # Displays info
M190 S{target_bed} # Sets the target temp for the bed
SET_DISPLAY_TEXT MSG="Z-tilt adjust" # Displays info
Z_TILT_ADJUST # Levels the buildplate via z_tilt_adjust
G28 Z # Homes Z after z_tilt_adjust
## Comment the below line if using bed mesh each print
BED_MESH_PROFILE LOAD="default"
## Uncomment for KAMP mesh (2 of 2)
# SET_DISPLAY_TEXT MSG="Creating Bed mesh" # Displays info
# BED_MESH_CALIBRATE # Starts bed mesh
# G28 Z # Homes Z after bed_mesh_calibrate
# Heats up the nozzle up to target via data from the slicer
SET_DISPLAY_TEXT MSG="Hotend: {target_extruder}c" # Displays info
M107 # Turns off partcooling fan
M109 S{target_extruder} # Heats the nozzle to printing temp
# Do a purge line, then start the print
SET_DISPLAY_TEXT MSG="Printing" # Displays info
# Standard Purge
G0 X{x_wait - 50} Y4 F10000 # Moves to starting point
G0 Z0.4 # Raises Z to 0.4
G91 # Incremental positioning
G1 X100 E20 F1000 # Purge line
# KAMP Purge
# LINE_PURGE
G90 # Absolut position
[gcode_macro PRINT_END]
gcode:
{% set x_park = printer.toolhead.axis_maximum.x|float - 3.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 3.0 %}
SET_DISPLAY_TEXT MSG="Finished Printing"
M104 S0
M140 S0
G92 E1
G1 E-1 F300 #Retract the filament
G90
G1 X{x_park} Y{y_park} F6000
M18 # Unlock Stepper Motors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment