chiark / gitweb /
Pause At Z improvements
authorpmsimard <pierrem.simard@gmail.com>
Thu, 8 Jan 2015 06:24:43 +0000 (01:24 -0500)
committerpmsimard <pierrem.simard@gmail.com>
Thu, 8 Jan 2015 06:24:43 +0000 (01:24 -0500)
- Support for Print one at a time mode
- Adding support to give the z move wanted. Z move check the max height of the printer
- Z move before XY now to prevent hitting the glass locks of the UM2

plugins/pauseAtZ.py

index 53a450c6af148a4d750914c847a35c62ebe8dbcc..7a77ccfe2358a74386755a46b7ad59a9f48e72fc 100644 (file)
@@ -5,10 +5,12 @@
 #Param: pauseLevel(float:5.0) Pause height (mm)
 #Param: parkX(float:190) Head park X (mm)
 #Param: parkY(float:190) Head park Y (mm)
+#Param: moveZ(float:0) Head move Z (mm)
 #Param: retractAmount(float:5) Retraction amount (mm)
 
 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
 import re
+from Cura.util import profile
 
 def getValue(line, key, default = None):
        if not key in line or (';' in line and line.find(key) > line.find(';')):
@@ -43,7 +45,7 @@ with open(filename, "w") as f:
                        y = getValue(line, 'Y', y)
                        if newZ != z and currentSectionType != 'CUSTOM':
                                z = newZ
-                               if z < pauseLevel and pauseState == 0:
+                               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.
                                        pauseState = 1
                                if z >= pauseLevel and pauseState == 1:
                                        pauseState = 2
@@ -51,10 +53,26 @@ with open(filename, "w") as f:
                                        #Retract
                                        f.write("M83\n")
                                        f.write("G1 E-%f F6000\n" % (retractAmount))
+
+                                       zChanged = False
+                                       #Change z before doing the move because the nozzle can hit the glass lock on the UM2
+                                       if z + moveZ < 15:
+                                               zChanged = True
+                                               f.write("G1 Z15 F300\n")
+
+                                       elif moveZ > 0:
+                                               newZ = z + moveZ
+                                               maxZ = profile.getMachineSettingFloat('machine_height') - 10 #For Safety Leave a 10mm space (endstop)
+                                               if maxZ < newZ:
+                                                       newZ = maxZ
+
+                                               if newZ > z:
+                                                       zChanged = True
+                                                       f.write("G1 Z%f F300\n" % (newZ))
+
                                        #Move the head away
                                        f.write("G1 X%f Y%f F9000\n" % (parkX, parkY))
-                                       if z < 15:
-                                               f.write("G1 Z15 F300\n")
+
                                        #Disable the E steppers
                                        f.write("M84 E0\n")
                                        #Wait till the user continues printing
@@ -62,10 +80,13 @@ with open(filename, "w") as f:
                                        #Push the filament back, and retract again, the properly primes the nozzle when changing filament.
                                        f.write("G1 E%f F6000\n" % (retractAmount))
                                        f.write("G1 E-%f F6000\n" % (retractAmount))
-                                       #Move the head back
-                                       if z < 15:
-                                               f.write("G1 Z%f F300\n" % (z+1))
-                                       f.write("G1 X%f Y%f F9000\n" % (x, y))
+
+                                       #Move the head back. Move Z at the same time to prevent hitting the glass locks on the UM2
+                                       if zChanged :
+                                               f.write("G1 X%f Y%f Z%f F9000\n" % (x, y, z+1))
+                                       else:
+                                               f.write("G1 X%f Y%f F9000\n" % (x, y))
+
                                        f.write("G1 E%f F6000\n" % (retractAmount))
                                        f.write("G1 F9000\n")
                                        f.write("M82\n")