Ver código fonte

- updated the preprocessor files

Marius Stanciu 6 anos atrás
pai
commit
6744d9ae07

+ 1 - 0
README.md

@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
 - fixed issue with clear_polygon3() - the one who makes 'lines' and fixed the NCC Tool
 - some small changes in the FlatCAMGeoemtry.on_tool_add() method
 - made sure that in Geometry Editor the self.app.mouse attribute is updated with the current mouse position (x, y)
+- updated the preprocessor files
 
 15.12.2019
 

+ 0 - 1
preprocessors/Berta_CNC.py

@@ -100,7 +100,6 @@ class Berta_CNC(FlatCAMPostProc):
         z_toolchange = p.z_toolchange
         toolchangexy = p.xy_toolchange
         f_plunge = p.f_plunge
-        gcode = ''
 
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]

+ 9 - 9
preprocessors/ISEL_CNC.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Matthieu Berthomé                           #
 # Date: 5/26/2017                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -71,15 +71,15 @@ class ISEL_CNC(FlatCAMPostProc):
 
     def startz_code(self, p):
         if p.startz is not None:
-            return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.startz)
+            return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.startz)
         else:
             return ''
 
     def lift_code(self, p):
-        return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.z_move)
+        return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
 
     def down_code(self, p):
-        return 'G01 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut)
+        return 'G01 Z' + self.coordinate_format % (p.coords_decimals, p.z_cut)
 
     def toolchange_code(self, p):
         f_plunge = p.f_plunge
@@ -130,17 +130,17 @@ M01""".format(tool=int(p.tool), toolC=toolC_formatted)
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
 
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         return gcode
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -153,5 +153,5 @@ M01""".format(tool=int(p.tool), toolC=toolC_formatted)
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 36 - 42
preprocessors/ISEL_ICP_CNC.py

@@ -1,16 +1,15 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Matthieu Berthomé, Daniel Friderich         #
-# Date: 12/15/2019                                          #
+# Date: 12/15/2019                                         #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
 
 class ISEL_ICP_CNC(FlatCAMPostProc):
-
     include_header = False
 
     def start_code(self, p):
@@ -22,47 +21,40 @@ class ISEL_ICP_CNC(FlatCAMPostProc):
         xmax = '%.*f' % (p.coords_decimals, p['options']['xmax'])
         ymin = '%.*f' % (p.coords_decimals, p['options']['ymin'])
         ymax = '%.*f' % (p.coords_decimals, p['options']['ymax'])
-        
-        gcode += 'IMF_PBL flatcam\r\n'
-        
-        if str(p['options']['type']) == 'Geometry':
-            gcode += '; TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + '\r\n'
-            
-        gcode += '; Spindle Speed: %s RPM\r\n' % str(p['spindlespeed'])
 
-        gcode += '; Feedrate: ' + str(p['feedrate']) + units + '/min' + '\r\n'
+        gcode += 'IMF_PBL flatcam\n\n'
 
         if str(p['options']['type']) == 'Geometry':
-            gcode += '; Feedrate_Z: ' + str(p['z_feedrate']) + units + '/min' + '\r\n'
-
-        gcode += '; Feedrate rapids ' + str(p['feedrate_rapid']) + units + '/min' + '\r\n\r\n'
-        gcode += '; Z_Cut: ' + str(p['z_cut']) + units + '\r\n'
+            gcode += '; TOOL DIAMETER: ' + str(p['options']['tool_dia']) + units + '\n'
+        gcode += '; Spindle Speed: %s RPM\n' % str(p['spindlespeed'])
+        gcode += '; Feedrate: ' + str(p['feedrate']) + units + '/min' + '\n'
+        if str(p['options']['type']) == 'Geometry':
+            gcode += '; Feedrate_Z: ' + str(p['z_feedrate']) + units + '/min' + '\n'
+        gcode += '\n'
+        gcode += '; Z_Cut: ' + str(p['z_cut']) + units + '\n'
 
         if str(p['options']['type']) == 'Geometry':
             if p['multidepth'] is True:
                 gcode += '; DepthPerCut: ' + str(p['z_depthpercut']) + units + ' <=>' + \
-                         str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + '\r\n'
-
-        gcode += '; Z_Move: ' + str(p['z_move']) + units + '\r\n'
-        gcode += '; Z Toolchange: ' + str(p['z_toolchange']) + units + '\r\n'
-
+                         str(math.ceil(abs(p['z_cut']) / p['z_depthpercut'])) + ' passes' + '\n'
+        gcode += '; Z_Move: ' + str(p['z_move']) + units + '\n'
+        gcode += '; Z Toolchange: ' + str(p['z_toolchange']) + units + '\n'
         if coords_xy is not None:
             gcode += '; X,Y Toolchange: ' + "%.*f, %.*f" % (p.decimals, coords_xy[0],
-                                                           p.decimals, coords_xy[1]) + units + '\r\n'
+                                                            p.decimals, coords_xy[1]) + units + '\n'
         else:
-            gcode += '; X,Y Toolchange: ' + "None" + units + '\r\n'
-
-        gcode += '; Z Start: ' + str(p['startz']) + units + '\r\n'
-        gcode += '; Z End: ' + str(p['z_end']) + units + '\r\n'
-        gcode += '; Steps per circle: ' + str(p['steps_per_circle']) + '\r\n'
-
+            gcode += '; X,Y Toolchange: ' + "None" + units + '\n'
+        gcode += '; Z Start: ' + str(p['startz']) + units + '\n'
+        gcode += '; Z End: ' + str(p['z_end']) + units + '\n'
+        gcode += '; Steps per circle: ' + str(p['steps_per_circle']) + '\n'
         if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
-            gcode += '; Preprocessor Excellon: ' + str(p['pp_excellon_name']) + '\r\n'
+            gcode += '; Preprocessor Excellon: ' + str(p['pp_excellon_name']) + '\n'
         else:
-            gcode += '; Preprocessor Geometry: ' + str(p['pp_geometry_name']) + '\r\n'
+            gcode += '; Preprocessor Geometry: ' + str(p['pp_geometry_name']) + '\n'
+        gcode += '\n'
 
-        gcode += '; X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + '\r\n'
-        gcode += '; Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + '\r\n'
+        gcode += '; X range: ' + '{: >9s}'.format(xmin) + ' ... ' + '{: >9s}'.format(xmax) + ' ' + units + '\n'
+        gcode += '; Y range: ' + '{: >9s}'.format(ymin) + ' ... ' + '{: >9s}'.format(ymax) + ' ' + units + '\n'
 
         return gcode
 
@@ -89,24 +81,26 @@ class ISEL_ICP_CNC(FlatCAMPostProc):
                 if i[0] == p.tool:
                     no_drills = i[2]
 
-            gcode = "GETTOOL {tool}\r\n; Changed to Tool Dia = {toolC}".format(tool=int(p.tool), t_drills=no_drills, toolC=toolC_formatted)
+            gcode = "GETTOOL {tool}\n; Changed to Tool Dia = {toolC}".format(tool=int(p.tool), t_drills=no_drills,
+                                                                             toolC=toolC_formatted)
 
             if f_plunge is True:
-                gcode += '\r\nFASTABS Z' + str(int(p.z_move * 1000))
+                gcode += '\nFASTABS Z' + str(int(p.z_move * 1000))
             return gcode
 
         else:
-            gcode = "GETTOOL {tool}\r\n; Changed to Tool Dia = {toolC})".format(tool=int(p.tool), toolC=toolC_formatted)
+            gcode = "GETTOOL {tool}\n; Changed to Tool Dia = {toolC}".format(tool=int(p.tool), toolC=toolC_formatted)
 
             if f_plunge is True:
-                gcode += '\r\nFASTABS Z' + str(int(p.z_move * 1000))
+                gcode += '\nFASTABS Z' + str(int(p.z_move * 1000))
             return gcode
 
     def up_to_zero_code(self, p):
         return 'MOVEABS Z0'
 
     def position_code(self, p):
-        return ('X' + str(int(p.x * 1000)) + ' Y' + str(int(p.y * 1000)))
+        return 'X' + str(int(p.x * 1000)) + ' Y' + str(int(p.y * 1000))
+
     def rapid_code(self, p):
         return ('FASTABS ' + self.position_code(p)).format(**p)
 
@@ -115,9 +109,9 @@ class ISEL_ICP_CNC(FlatCAMPostProc):
 
     def end_code(self, p):
         gcode = ''
-        gcode += 'WPCLEAR\r\n'
-        gcode += 'FASTABS Z0\r\n'
-        gcode += 'FASTABS X0 Y0\r\n'
+        gcode += 'WPCLEAR\n'
+        gcode += 'FASTABS Z0\n'
+        gcode += 'FASTABS X0 Y0\n'
         gcode += 'PROGEND'
         return gcode
 
@@ -138,5 +132,5 @@ class ISEL_ICP_CNC(FlatCAMPostProc):
         if p.dwelltime:
             return 'WAIT ' + str(int(p.dwelltime * 1000))
 
-    def spindle_stop_code(self,p):
-        return 'SPINDLE OFF'
+    def spindle_stop_code(self, p):
+        return 'SPINDLE OFF'

+ 12 - 13
preprocessors/Paste_1.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -57,21 +57,20 @@ class Paste_1(FlatCAMPostProc_Tools):
         return gcode
 
     def lift_code(self, p):
-        return 'G00 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_travel']))
+        return 'G00 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_travel']))
 
     def down_z_start_code(self, p):
-        return 'G01 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_start']))
+        return 'G01 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_start']))
 
     def lift_z_dispense_code(self, p):
-        return 'G01 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_dispense']))
+        return 'G01 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_dispense']))
 
     def down_z_stop_code(self, p):
-        return 'G01 Z' + self.coordinate_format%(p.coords_decimals, float(p['z_stop']))
+        return 'G01 Z' + self.coordinate_format % (p.coords_decimals, float(p['z_stop']))
 
     def toolchange_code(self, p):
         z_toolchange = float(p['z_toolchange'])
         toolchangexy = [float(eval(a)) for a in p['xy_toolchange'].split(",") if a != '']
-        gcode = ''
 
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
@@ -117,27 +116,27 @@ G00 Z{z_toolchange}
 
     def rapid_code(self, p):
         return ('G00 ' + self.position_code(p)).format(**p) + '\nG00 Z' + \
-               self.coordinate_format%(p.coords_decimals, float(p['z_travel']))
+               self.coordinate_format % (p.coords_decimals, float(p['z_travel']))
 
     def linear_code(self, p):
         return ('G01 ' + self.position_code(p)).format(**p)
 
     def end_code(self, p):
         coords_xy = [float(eval(a)) for a in p['xy_toolchange'].split(",") if a != '']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, float(p['z_toolchange'])) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, float(p['z_toolchange'])) + "\n")
 
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         return gcode
 
     def feedrate_xy_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, float(p['frxy'])))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, float(p['frxy'])))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, float(p['frz'])))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, float(p['frz'])))
 
     def feedrate_z_dispense_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, float(p['frz_dispense'])))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, float(p['frz_dispense'])))
 
     def spindle_fwd_code(self, p):
         if p.spindlespeed:
@@ -151,7 +150,7 @@ G00 Z{z_toolchange}
         else:
             return 'M04'
 
-    def spindle_off_code(self,p):
+    def spindle_off_code(self, p):
         return 'M05'
 
     def dwell_fwd_code(self, p):

+ 15 - 13
preprocessors/Repetier.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -78,20 +78,22 @@ class Repetier(FlatCAMPostProc):
             return ''
 
     def lift_code(self, p):
-        return 'G0 Z' + self.coordinate_format%(p.coords_decimals, p.z_move) + " " + self.feedrate_rapid_code(p)
+        return 'G0 Z' + self.coordinate_format % (p.coords_decimals, p.z_move) + " " + self.feedrate_rapid_code(p)
 
     def down_code(self, p):
-        return 'G1 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut) + " " + self.inline_z_feedrate_code(p)
+        return 'G1 Z' + self.coordinate_format % (p.coords_decimals, p.z_cut) + " " + self.inline_z_feedrate_code(p)
 
     def toolchange_code(self, p):
         z_toolchange = p.z_toolchange
         toolchangexy = p.xy_toolchange
         f_plunge = p.f_plunge
-        gcode = ''
 
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
+        else:
+            x_toolchange = 0.0
+            y_toolchange = 0.0
 
         no_drills = 1
 
@@ -153,7 +155,7 @@ G0 Z{z_toolchange}
 M84
 @pause Change to tool T{tool} with Tool Dia = {toolC}
 G0 Z{z_toolchange}
-""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
+""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            tool=int(p.tool),
            toolC=toolC_formatted)
 
@@ -177,7 +179,7 @@ G0 Z{z_toolchange}
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G0 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n")
+        gcode = ('G0 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n")
 
         if coords_xy is not None:
             gcode += 'G0 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + " " + self.feedrate_rapid_code(p) + "\n"
@@ -185,21 +187,21 @@ G0 Z{z_toolchange}
         return gcode
 
     def feedrate_code(self, p):
-        return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G1 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def inline_feedrate_code(self, p):
-        return 'F' + self.feedrate_format %(p.fr_decimals, p.feedrate)
+        return 'F' + self.feedrate_format % (p.fr_decimals, p.feedrate)
 
     def inline_z_feedrate_code(self, p):
-        return 'F' + self.feedrate_format %(p.fr_decimals, p.z_feedrate)
+        return 'F' + self.feedrate_format % (p.fr_decimals, p.z_feedrate)
 
     def z_feedrate_code(self, p):
-        return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G1 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def feedrate_rapid_code(self, p):
         return 'F' + self.feedrate_rapid_format % (p.fr_decimals, p.feedrate_rapid)
 
-    def spindle_code(self,p):
+    def spindle_code(self, p):
         if p.spindlespeed:
             return 'M106 S%d' % p.spindlespeed
         else:
@@ -209,5 +211,5 @@ G0 Z{z_toolchange}
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M107'

+ 3 - 3
preprocessors/Roland_MDX_20.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -124,5 +124,5 @@ class Roland_MDX_20(FlatCAMPostProc):
     def dwell_code(self, p):
         return''
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return '!MC0'

+ 11 - 8
preprocessors/Toolchange_Custom.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -75,10 +75,10 @@ class Toolchange_Custom(FlatCAMPostProc):
         return ''
 
     def lift_code(self, p):
-        return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.z_move)
+        return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
 
     def down_code(self, p):
-        return 'G01 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut)
+        return 'G01 Z' + self.coordinate_format % (p.coords_decimals, p.z_cut)
 
     def toolchange_code(self, p):
         z_toolchange = p.z_toolchange
@@ -89,6 +89,9 @@ class Toolchange_Custom(FlatCAMPostProc):
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
+        else:
+            x_toolchange = 0.0
+            y_toolchange = 0.0
 
         no_drills = 1
 
@@ -143,17 +146,17 @@ M6
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
 
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         return gcode
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -166,5 +169,5 @@ M6
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 13 - 12
preprocessors/Toolchange_Probe_MACH3.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -90,11 +90,12 @@ class Toolchange_Probe_MACH3(FlatCAMPostProc):
         toolchangexy = p.xy_toolchange
         f_plunge = p.f_plunge
 
-        gcode = ''
-
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
+        else:
+            x_toolchange = 0.0
+            y_toolchange = 0.0
 
         no_drills = 1
 
@@ -132,7 +133,7 @@ M0
            z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
            z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
-           feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
+           feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
            feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
            z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
            tool=int(p.tool),
@@ -159,7 +160,7 @@ M0
 """.format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
            z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
-           feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
+           feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
            feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
            z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
            tool=int(p.tool),
@@ -195,7 +196,7 @@ M0
            z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
            z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
-           feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
+           feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
            feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
            z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
            tool=int(p.tool),
@@ -221,7 +222,7 @@ M0
 """.format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            z_move=self.coordinate_format % (p.coords_decimals, p.z_move),
            z_in_between=self.coordinate_format % (p.coords_decimals, p.z_move / 2),
-           feedrate_probe=str(self.feedrate_format %(p.fr_decimals, p.feedrate_probe)),
+           feedrate_probe=str(self.feedrate_format % (p.fr_decimals, p.feedrate_probe)),
            feedrate_probe_slow=str(self.feedrate_format % (p.fr_decimals, (p.feedrate_probe / 2))),
            z_pdepth=self.coordinate_format % (p.coords_decimals, p.z_pdepth),
            tool=int(p.tool),
@@ -246,17 +247,17 @@ M0
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
 
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         return gcode
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -269,5 +270,5 @@ M0
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 17 - 16
preprocessors/Toolchange_manual.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -85,11 +85,13 @@ class Toolchange_manual(FlatCAMPostProc):
         z_toolchange = p.z_toolchange
         toolchangexy = p.xy_toolchange
         f_plunge = p.f_plunge
-        gcode = ''
 
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
+        else:
+            x_toolchange = 0.0
+            y_toolchange = 0.0
 
         no_drills = 1
 
@@ -117,9 +119,9 @@ M0
 G00 Z{z_toolchange}
 (MSG, Now the tool can be tightened more securely.)
 M0
-""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
-           y_toolchange=self.coordinate_format%(p.coords_decimals, y_toolchange),
-           z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
+""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
+           y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
+           z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            tool=int(p.tool),
            t_drills=no_drills,
            toolC=toolC_formatted)
@@ -138,7 +140,7 @@ G00 Z{z_toolchange}
 (MSG, Now the tool can be tightened more securely.)
 M0
 """.format(
-           z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
+           z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            tool=int(p.tool),
            t_drills=no_drills,
            toolC=toolC_formatted)
@@ -162,9 +164,9 @@ M0
 G00 Z{z_toolchange}
 (MSG, Now the tool can be tightened more securely.)
 M0
-""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
-           y_toolchange=self.coordinate_format%(p.coords_decimals, y_toolchange),
-           z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
+""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
+           y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
+           z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            tool=int(p.tool),
            toolC=toolC_formatted)
             else:
@@ -180,8 +182,7 @@ M0
 G00 Z{z_toolchange}
 (MSG, Now the tool can be tightened more securely.)
 M0
-""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
-           tool=int(p.tool),
+""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange), tool=int(p.tool),
            toolC=toolC_formatted)
 
             if f_plunge is True:
@@ -203,7 +204,7 @@ M0
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         else:
@@ -211,10 +212,10 @@ M0
         return gcode
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -227,5 +228,5 @@ M0
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 13 - 11
preprocessors/default.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Matthieu Berthomé                           #
 # Date: 5/26/2017                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -72,25 +72,27 @@ class default(FlatCAMPostProc):
 
     def startz_code(self, p):
         if p.startz is not None:
-            return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.startz)
+            return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.startz)
         else:
             return ''
 
     def lift_code(self, p):
-        return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.z_move)
+        return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
 
     def down_code(self, p):
-        return 'G01 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut)
+        return 'G01 Z' + self.coordinate_format % (p.coords_decimals, p.z_cut)
 
     def toolchange_code(self, p):
         z_toolchange = p.z_toolchange
         toolchangexy = p.xy_toolchange
         f_plunge = p.f_plunge
-        gcode = ''
 
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
+        else:
+            x_toolchange = 0.0
+            y_toolchange = 0.0
 
         no_drills = 1
 
@@ -164,7 +166,7 @@ M6
 (MSG, Change to Tool Dia = {toolC})
 M0
 G00 Z{z_toolchange}
-""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
+""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            tool=int(p.tool),
            toolC=toolC_formatted)
 
@@ -187,17 +189,17 @@ G00 Z{z_toolchange}
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
 
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         return gcode
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -210,5 +212,5 @@ G00 Z{z_toolchange}
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 14 - 12
preprocessors/grbl_11.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Matthieu Berthomé                           #
 # Date: 5/26/2017                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -71,25 +71,27 @@ class grbl_11(FlatCAMPostProc):
 
     def startz_code(self, p):
         if p.startz is not None:
-            return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.startz)
+            return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.startz)
         else:
             return ''
 
     def lift_code(self, p):
-        return 'G00 Z' + self.coordinate_format%(p.coords_decimals, p.z_move)
+        return 'G00 Z' + self.coordinate_format % (p.coords_decimals, p.z_move)
 
     def down_code(self, p):
-        return 'G01 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut)
+        return 'G01 Z' + self.coordinate_format % (p.coords_decimals, p.z_cut)
 
     def toolchange_code(self, p):
         z_toolchange = p.z_toolchange
         toolchangexy = p.xy_toolchange
         f_plunge = p.f_plunge
-        gcode = ''
 
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
+        else:
+            x_toolchange = 0.0
+            y_toolchange = 0.0
 
         no_drills = 1
 
@@ -162,7 +164,7 @@ M6
 (MSG, Change to Tool Dia = {toolC})
 M0
 G00 Z{z_toolchange}
-""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
+""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            tool=int(p.tool),
            toolC=toolC_formatted)
 
@@ -182,21 +184,21 @@ G00 Z{z_toolchange}
 
     def linear_code(self, p):
         return ('G01 ' + self.position_code(p)).format(**p) + \
-               ' F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+               ' F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
 
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         return gcode
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -209,5 +211,5 @@ G00 Z{z_toolchange}
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 7 - 7
preprocessors/grbl_laser.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Matthieu Berthomé                           #
 # Date: 5/26/2017                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -74,21 +74,21 @@ class grbl_laser(FlatCAMPostProc):
 
     def linear_code(self, p):
         return ('G01 ' + self.position_code(p)).format(**p) + \
-               ' F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+               ' F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G00 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + "\n")
+        gcode = ('G00 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + "\n")
 
         if coords_xy is not None:
             gcode += 'G00 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + "\n"
         return gcode
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -100,5 +100,5 @@ class grbl_laser(FlatCAMPostProc):
     def dwell_code(self, p):
         return ''
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 3 - 3
preprocessors/hpgl.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -80,5 +80,5 @@ class hpgl(FlatCAMPostProc):
     def dwell_code(self, p):
         return ''
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return ''

+ 11 - 12
preprocessors/line_xyz.py

@@ -1,10 +1,10 @@
-# ########################################################## ##
+# ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # http://flatcam.org                                       #
 # File Author: Marius Adrian Stanciu (c)                   #
 # Date: 3/10/2019                                          #
 # MIT Licence                                              #
-# ########################################################## ##
+# ##########################################################
 
 from FlatCAMPostProc import *
 
@@ -70,9 +70,9 @@ class line_xyz(FlatCAMPostProc):
 
     def startz_code(self, p):
         if p.startz is not None:
-            g = 'G00 ' + 'X' + self.coordinate_format%(p.coords_decimals, p.x) + \
-                ' Y' + self.coordinate_format%(p.coords_decimals, p.y) + \
-                ' Z' + self.coordinate_format%(p.coords_decimals, p.startz)
+            g = 'G00 ' + 'X' + self.coordinate_format % (p.coords_decimals, p.x) + \
+                ' Y' + self.coordinate_format % (p.coords_decimals, p.y) + \
+                ' Z' + self.coordinate_format % (p.coords_decimals, p.startz)
             return g
         else:
             return ''
@@ -93,7 +93,6 @@ class line_xyz(FlatCAMPostProc):
         z_toolchange = p.z_toolchange
         xy_toolchange = p.xy_toolchange
         f_plunge = p.f_plunge
-        gcode = ''
 
         if xy_toolchange is not None:
             x_toolchange = xy_toolchange[0]
@@ -123,7 +122,7 @@ G00 X{x_toolchange} Y{x_toolchange} Z{z_toolchange}
 T{tool}
 M6
 (MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
-M0""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
+M0""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
              y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
              z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
              tool=int(p.tool),
@@ -132,7 +131,7 @@ M0""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchang
 
             if f_plunge is True:
                 gcode += """\nG00 X{x_toolchange} Y{x_toolchange} Z{z_move}""".format(
-                    x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
+                    x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
                     y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
                     z_move=self.coordinate_format % (p.coords_decimals, p.z_move))
             return gcode
@@ -143,7 +142,7 @@ G00 X{x_toolchange} Y{x_toolchange} Z{z_toolchange}
 T{tool}
 M6    
 (MSG, Change to Tool Dia = {toolC})
-M0""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchange),
+M0""".format(x_toolchange=self.coordinate_format % (p.coords_decimals, x_toolchange),
              y_toolchange=self.coordinate_format % (p.coords_decimals, y_toolchange),
              z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
              tool=int(p.tool),
@@ -186,10 +185,10 @@ M0""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchang
         return g
 
     def feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def z_feedrate_code(self, p):
-        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G01 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def spindle_code(self, p):
         sdir = {'CW': 'M03', 'CCW': 'M04'}[p.spindledir]
@@ -202,5 +201,5 @@ M0""".format(x_toolchange=self.coordinate_format%(p.coords_decimals, x_toolchang
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M05'

+ 12 - 10
preprocessors/marlin.py

@@ -78,20 +78,22 @@ class marlin(FlatCAMPostProc):
             return ''
 
     def lift_code(self, p):
-        return 'G0 Z' + self.coordinate_format%(p.coords_decimals, p.z_move) + " " + self.feedrate_rapid_code(p)
+        return 'G0 Z' + self.coordinate_format % (p.coords_decimals, p.z_move) + " " + self.feedrate_rapid_code(p)
 
     def down_code(self, p):
-        return 'G1 Z' + self.coordinate_format%(p.coords_decimals, p.z_cut) + " " + self.inline_z_feedrate_code(p)
+        return 'G1 Z' + self.coordinate_format % (p.coords_decimals, p.z_cut) + " " + self.inline_z_feedrate_code(p)
 
     def toolchange_code(self, p):
         z_toolchange = p.z_toolchange
         toolchangexy = p.xy_toolchange
         f_plunge = p.f_plunge
-        gcode = ''
 
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
+        else:
+            x_toolchange = 0.0
+            y_toolchange = 0.0
 
         no_drills = 1
 
@@ -164,7 +166,7 @@ M6
 ;MSG, Change to Tool Dia = {toolC}
 M0
 G0 Z{z_toolchange}
-""".format(z_toolchange=self.coordinate_format%(p.coords_decimals, z_toolchange),
+""".format(z_toolchange=self.coordinate_format % (p.coords_decimals, z_toolchange),
            tool=int(p.tool),
            toolC=toolC_formatted)
 
@@ -187,7 +189,7 @@ G0 Z{z_toolchange}
 
     def end_code(self, p):
         coords_xy = p['xy_toolchange']
-        gcode = ('G0 Z' + self.feedrate_format %(p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n")
+        gcode = ('G0 Z' + self.feedrate_format % (p.fr_decimals, p.z_end) + " " + self.feedrate_rapid_code(p) + "\n")
 
         if coords_xy is not None:
             gcode += 'G0 X{x} Y{y}'.format(x=coords_xy[0], y=coords_xy[1]) + " " + self.feedrate_rapid_code(p) + "\n"
@@ -195,16 +197,16 @@ G0 Z{z_toolchange}
         return gcode
 
     def feedrate_code(self, p):
-        return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
+        return 'G1 F' + str(self.feedrate_format % (p.fr_decimals, p.feedrate))
 
     def inline_feedrate_code(self, p):
-        return 'F' + self.feedrate_format %(p.fr_decimals, p.feedrate)
+        return 'F' + self.feedrate_format % (p.fr_decimals, p.feedrate)
 
     def inline_z_feedrate_code(self, p):
-        return 'F' + self.feedrate_format %(p.fr_decimals, p.z_feedrate)
+        return 'F' + self.feedrate_format % (p.fr_decimals, p.z_feedrate)
 
     def z_feedrate_code(self, p):
-        return 'G1 F' + str(self.feedrate_format %(p.fr_decimals, p.z_feedrate))
+        return 'G1 F' + str(self.feedrate_format % (p.fr_decimals, p.z_feedrate))
 
     def feedrate_rapid_code(self, p):
         return 'F' + self.feedrate_rapid_format % (p.fr_decimals, p.feedrate_rapid)
@@ -220,5 +222,5 @@ G0 Z{z_toolchange}
         if p.dwelltime:
             return 'G4 P' + str(p.dwelltime)
 
-    def spindle_stop_code(self,p):
+    def spindle_stop_code(self, p):
         return 'M5'