Skip to content

Instantly share code, notes, and snippets.

@chrisvaughn
Last active July 2, 2024 11:49
Show Gist options
  • Save chrisvaughn/71e06075371fd02a476d71999ce94d5e to your computer and use it in GitHub Desktop.
Save chrisvaughn/71e06075371fd02a476d71999ce94d5e to your computer and use it in GitHub Desktop.
Cura 5.7.2 Custom Configurations for Ender 3 v2 w/ BL Touch

copy start.gcode and end.gcode to your printers settings

To deal with Ultimaker/Cura#19204 open Cura's configuration directory (Cura -> Help -> Show Configuration Folder) copy CuraPrependBugFix.py to the scripts folder

in Cura -> Extensions -> Post Processing -> Modify G-Code -> "Add A Script" find "Cura Prepend Temperature Bugfix" and enable

# Authored by: GregValiant (Greg Foresi) 6/24
# Removes the M104 and M109 hot end temperature prepend lines if 'material_print_temperature' is in the StartUp Gcode (also covers 'material_print_temperature_layer_0')
# Removes the M140 and M190 bed temperature prepend lines if 'material_bed_temperature' is in the StartUp Gcode (also covers 'material_bed_temperature_layer_0')
# source https://github.com/Ultimaker/Cura/issues/19204#issuecomment-2163070633
from ..Script import Script
from UM.Application import Application
class CuraPrependBugFix(Script):
def getSettingDataString(self):
return """{
"name": "Cura Prepend Temperature Bugfix",
"key": "CuraPrependBugFix",
"metadata": {},
"version": 2,
"settings":
{
"enable_prepend_bugfix":
{
"label": "Enable this script",
"description": "When enabled the script will check if Bed and Hot End temperature prepends were required. It will go ahead and remove the prepend temperature lines from before the StartUp Gcode if they were not.",
"type": "bool",
"default_value": true,
"enabled": true
}
}
}"""
def execute(self, data):
# Exit if the script is not enabled
if not bool(self.getSettingValueByKey("enable_prepend_bugfix")):
return data
startup = data[1].split("\n")
startup_gcode = Application.getInstance().getGlobalContainerStack().getProperty("machine_start_gcode", "value")
prepend_hot_end = True
prepend_bed = True
modified_data = []
# Check the startup gcode for hot end temperature replacement patterns (keywords)
if "material_print_temperature" in startup_gcode:
prepend_hot_end = False
# Check the startup gcode for bed temperature replacement patterns (keywords)
if "material_bed_temperature" in startup_gcode:
prepend_bed = False
# If the prepend is required then exit.
if prepend_hot_end and prepend_bed:
return data
for index, line in enumerate(startup):
first_part = startup[index][0:4]
if not prepend_hot_end:
if first_part in ["M104", "M109"]:
continue
if not prepend_bed:
if first_part in ["M140", "M190"]:
continue
if not prepend_hot_end and not prepend_bed:
if first_part == "M105":
continue
# Once the M82 line is reached then we are past the prepend lines so just continue.
if line.startswith("M82"):
prepend_hot_end = True
prepend_bed = True
modified_data.append(line)
data[1] = "\n".join(modified_data)
return data
G91 ;Relative positioning
G1 E-2 F2700 ;Retract a bit
G1 E-2 Z0.2 F2400 ;Retract and raise Z
G1 X5 Y5 F3000 ;Wipe out
G1 Z10 ;Raise Z more
G90 ;Absolute positioning
G1 X0 Y{machine_depth} ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M84 X Y E ;Disable all steppers but Z
; Ender 3 Custom Start G-code
G92 E0 ; Reset Extruder
M140 S{material_bed_temperature_layer_0} ; set final bed temp
M104 S160 ; set temporary nozzle temp to prevent oozing during homing
G4 S10 ; allow partial nozzle warmup
G28 ; Home all axes
G29 ; BL Touch
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
M104 S{material_print_temperature_layer_0} ; set final nozzle temp
M190 S{material_bed_temperature_layer_0} ; wait for bed temp to stabilize
M109 S{material_print_temperature_layer_0} ; wait for nozzle temp to stabilize
G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line
G92 E0 ; Reset Extruder
G1 Z2.0 F3000 ; Move Z Axis up little to prevent scratching of Heat Bed
G1 X5 Y20 Z0.3 F5000.0 ; Move over to prevent blob squish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment