From 6673c4f608c683170e88f0596b63802e6480e1cd Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 24 Jan 2019 19:22:02 +0200 Subject: [PATCH] - fixed 'grbl_laser' postprocessor bugs (missing functions) - fixed display geometry for 'grbl_laser' postprocessor --- README.md | 2 ++ camlib.py | 20 ++++++++++++++++++++ postprocessors/grbl_laser.py | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b5410d0..8128d90a 100644 --- a/README.md +++ b/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 diff --git a/camlib.py b/camlib.py index 675f1b4b..cc5aa313 100644 --- a/camlib.py +++ b/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 diff --git a/postprocessors/grbl_laser.py b/postprocessors/grbl_laser.py index b4c96ef8..02af15c1 100644 --- a/postprocessors/grbl_laser.py +++ b/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 ''