Просмотр исходного кода

- fixed 'grbl_laser' postprocessor bugs (missing functions)
- fixed display geometry for 'grbl_laser' postprocessor

Marius Stanciu 7 лет назад
Родитель
Сommit
6673c4f608
3 измененных файлов с 28 добавлено и 2 удалено
  1. 2 0
      README.md
  2. 20 0
      camlib.py
  3. 6 2
      postprocessors/grbl_laser.py

+ 2 - 0
README.md

@@ -16,6 +16,8 @@ CAD program, and create G-Code for Isolation routing.
 - added the Copy entry to the Project context menu
 - made the functions behind Disable and Enable project context menu entries, non-threaded to fix a possible issue
 - added multiple object selection on Open ... and Import ... (idea and code snippet came from Travers Carter, BitBucket user https://bitbucket.org/travc/
+- fixed 'grbl_laser' postprocessor bugs (missing functions)
+- fixed display geometry for 'grbl_laser' postprocessor
 
 23.01.2019
 

+ 20 - 0
camlib.py

@@ -5074,6 +5074,7 @@ class CNCjob(Geometry):
         self.gcode = self.doformat(p.start_code)
 
         self.gcode += self.doformat(p.feedrate_code)        # sets the feed rate
+
         self.gcode += self.doformat(p.lift_code, x=0, y=0)  # Move (up) to travel height
         self.gcode += self.doformat(p.startz_code, x=0, y=0)
 
@@ -5084,8 +5085,10 @@ class CNCjob(Geometry):
                 self.gcode += self.doformat(p.toolchange_code)
 
             self.gcode += self.doformat(p.spindle_code)     # Spindle start
+
             if self.dwell is True:
                 self.gcode += self.doformat(p.dwell_code)   # Dwell time
+
         else:
             self.gcode += self.doformat(p.spindle_code)     # Spindle start
             if self.dwell is True:
@@ -5243,6 +5246,21 @@ class CNCjob(Geometry):
                 else:
                     command['Z'] = 0
 
+        elif 'grbl_laser' in self.pp_excellon_name or 'grbl_laser' in self.pp_geometry_name:
+            match_lsr = re.search(r"X([\+-]?\d+.[\+-]?\d+)\s*Y([\+-]?\d+.[\+-]?\d+)", gline)
+            if match_lsr:
+                command['X'] = float(match_lsr.group(1).replace(" ", ""))
+                command['Y'] = float(match_lsr.group(2).replace(" ", ""))
+
+            match_lsr_pos = re.search(r"^(M0[3|5])", gline)
+            if match_lsr_pos:
+                if match_lsr_pos.group(1) == 'M05':
+                    # the value does not matter, only that it is positive so the gcode_parse() know it is > 0,
+                    # therefore the move is of kind T (travel)
+                    command['Z'] = 1
+                else:
+                    command['Z'] = 0
+
         else:
             match = re.search(r'^\s*([A-Z])\s*([\+\-\.\d\s]+)', gline)
             while match:
@@ -5293,6 +5311,8 @@ class CNCjob(Geometry):
                     pass
                 elif 'hpgl' in self.pp_excellon_name or 'hpgl' in self.pp_geometry_name:
                     pass
+                elif 'grbl_laser' in self.pp_excellon_name or 'grbl_laser' in self.pp_geometry_name:
+                    pass
                 elif ('X' in gobj or 'Y' in gobj) and gobj['Z'] != current['Z']:
                     if self.pp_geometry_name == 'line_xyz' or self.pp_excellon_name == 'line_xyz':
                         pass

+ 6 - 2
postprocessors/grbl_laser.py

@@ -22,7 +22,6 @@ class grbl_laser(FlatCAMPostProc):
             gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n'
         else:
             gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n'
-
         gcode += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n"
         gcode += 'G90\n'
         gcode += 'G94\n'
@@ -63,9 +62,14 @@ class grbl_laser(FlatCAMPostProc):
     def feedrate_code(self, p):
         return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate))
 
-    def spindle_code(self,p):
+    def feedrate_z_code(self, p):
+        return 'G01 F' + str(self.feedrate_format %(p.fr_decimals, p.feedrate_z))
+
+    def spindle_code(self, p):
         if p.spindlespeed:
             return 'S%d' % p.spindlespeed
+        else:
+            return ''
 
     def dwell_code(self, p):
         return ''