2 #Info: Pause the printer at a certain height
5 #Param: pauseLevel(float:5.0) Pause height (mm)
6 #Param: parkX(float:190) Head park X (mm)
7 #Param: parkY(float:190) Head park Y (mm)
8 #Param: moveZ(float:0) Head move Z (mm)
9 #Param: retractAmount(float:5) Retraction amount (mm)
11 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
13 from Cura.util import profile
15 def getValue(line, key, default = None):
16 if not key in line or (';' in line and line.find(key) > line.find(';')):
18 subPart = line[line.find(key) + 1:]
19 m = re.search('^[0-9]+\.?[0-9]*', subPart)
23 return float(m.group(0))
27 with open(filename, "r") as f:
34 currentSectionType = 'STARTOFFILE'
35 with open(filename, "w") as f:
37 if line.startswith(';'):
38 if line.startswith(';TYPE:'):
39 currentSectionType = line[6:].strip()
42 if getValue(line, 'G', None) == 1 or getValue(line, 'G', None) == 0:
43 newZ = getValue(line, 'Z', z)
44 x = getValue(line, 'X', x)
45 y = getValue(line, 'Y', y)
46 if newZ != z and currentSectionType != 'CUSTOM':
48 if z < pauseLevel and (pauseState == 0 or pauseState == 2): #pauseState going from 2 to 1 mean we can support print one at a time mode.
50 if z >= pauseLevel and pauseState == 1:
52 f.write(";TYPE:CUSTOM\n")
55 f.write("G1 E-%f F6000\n" % (retractAmount))
58 #Change z before doing the move because the nozzle can hit the glass lock on the UM2
61 f.write("G1 Z15 F300\n")
65 maxZ = profile.getMachineSettingFloat('machine_height') - 10 #For Safety Leave a 10mm space (endstop)
71 f.write("G1 Z%f F300\n" % (newZ))
74 f.write("G1 X%f Y%f F9000\n" % (parkX, parkY))
76 #Disable the E steppers
78 #Wait till the user continues printing
80 #Push the filament back, and retract again, the properly primes the nozzle when changing filament.
81 f.write("G1 E%f F6000\n" % (retractAmount))
82 f.write("G1 E-%f F6000\n" % (retractAmount))
84 #Move the head back. Move Z at the same time to prevent hitting the glass locks on the UM2
86 f.write("G1 X%f Y%f Z%f F9000\n" % (x, y, z+1))
88 f.write("G1 X%f Y%f F9000\n" % (x, y))
90 f.write("G1 E%f F6000\n" % (retractAmount))