Explorar el Código

- small changes in parse_gcode()

Marius Stanciu hace 6 años
padre
commit
23a1388e98
Se han modificado 3 ficheros con 13 adiciones y 7 borrados
  1. 12 3
      camlib.py
  2. 0 3
      postprocessors/Toolchange_manual.py
  3. 1 1
      postprocessors/default.py

+ 12 - 3
camlib.py

@@ -2612,7 +2612,7 @@ class CNCjob(Geometry):
 
 
                             # Tool change sequence (optional)
                             # Tool change sequence (optional)
                             if toolchange:
                             if toolchange:
-                                gcode += self.doformat(p.toolchange_code,toolchangexy=(self.oldx, self.oldy))
+                                gcode += self.doformat(p.toolchange_code, toolchangexy=(self.oldx, self.oldy))
                                 gcode += self.doformat(p.spindle_code)  # Spindle start
                                 gcode += self.doformat(p.spindle_code)  # Spindle start
                                 if self.dwell is True:
                                 if self.dwell is True:
                                     gcode += self.doformat(p.dwell_code)  # Dwell time
                                     gcode += self.doformat(p.dwell_code)  # Dwell time
@@ -3972,9 +3972,11 @@ class CNCjob(Geometry):
         path = [pos_xy]
         path = [pos_xy]
         # path = [(0, 0)]
         # path = [(0, 0)]
 
 
-        self.app.inform.emit('%s: %d' % (_("Parsing GCode file. Number of lines"), len(self.gcode.splitlines())))
+        gcode_lines_list = self.gcode.splitlines()
+        self.app.inform.emit('%s: %d' % (_("Parsing GCode file. Number of lines"), len(gcode_lines_list)))
+
         # Process every instruction
         # Process every instruction
-        for line in StringIO(self.gcode):
+        for line in gcode_lines_list:
             if force_parsing is False or force_parsing is None:
             if force_parsing is False or force_parsing is None:
                 if '%MO' in line or '%' in line or 'MOIN' in line or 'MOMM' in line:
                 if '%MO' in line or '%' in line or 'MOIN' in line or 'MOMM' in line:
                     return "fail"
                     return "fail"
@@ -3986,6 +3988,10 @@ class CNCjob(Geometry):
                 self.units = {20.0: "IN", 21.0: "MM"}[gobj['G']]
                 self.units = {20.0: "IN", 21.0: "MM"}[gobj['G']]
                 continue
                 continue
 
 
+            # TODO take into consideration the tools and update the travel line thickness
+            if 'T' in gobj:
+                pass
+
             # ## Changing height
             # ## Changing height
             if 'Z' in gobj:
             if 'Z' in gobj:
                 if 'Roland' in self.pp_excellon_name or 'Roland' in self.pp_geometry_name:
                 if 'Roland' in self.pp_excellon_name or 'Roland' in self.pp_geometry_name:
@@ -4067,6 +4073,9 @@ class CNCjob(Geometry):
                     stop = np.arctan2(-center[1] + y, -center[0] + x)
                     stop = np.arctan2(-center[1] + y, -center[0] + x)
                     path += arc(center, radius, start, stop, arcdir[current['G']], int(self.steps_per_circle / 4))
                     path += arc(center, radius, start, stop, arcdir[current['G']], int(self.steps_per_circle / 4))
 
 
+                current['X'] = x
+                current['Y'] = y
+
             # Update current instruction
             # Update current instruction
             for code in gobj:
             for code in gobj:
                 current[code] = gobj[code]
                 current[code] = gobj[code]

+ 0 - 3
postprocessors/Toolchange_manual.py

@@ -89,9 +89,6 @@ class Toolchange_manual(FlatCAMPostProc):
         if toolchangexy is not None:
         if toolchangexy is not None:
             x_toolchange = toolchangexy[0]
             x_toolchange = toolchangexy[0]
             y_toolchange = toolchangexy[1]
             y_toolchange = toolchangexy[1]
-        # else:
-        #     x_toolchange = p.oldx
-        #     y_toolchange = p.oldy
 
 
         no_drills = 1
         no_drills = 1
 
 

+ 1 - 1
postprocessors/default.py

@@ -107,8 +107,8 @@ class default(FlatCAMPostProc):
                 gcode = """
                 gcode = """
 M5
 M5
 G00 Z{z_toolchange}
 G00 Z{z_toolchange}
-G00 X{x_toolchange} Y{y_toolchange}                
 T{tool}
 T{tool}
+G00 X{x_toolchange} Y{y_toolchange}                
 M6
 M6
 (MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
 (MSG, Change to Tool Dia = {toolC} ||| Total drills for tool T{tool} = {t_drills})
 M0
 M0