From d45d2c05ec100ef37e600957b90d47b443655d3f Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 1 Feb 2019 00:23:20 +0200 Subject: [PATCH] - added the bounds coordinates to the GCODE header; modified the postprocessor files to show them. --- FlatCAMObj.py | 24 ++++++++++++++++++++++-- README.md | 1 + postprocessors/default.py | 7 ++++++- postprocessors/grbl_11.py | 7 ++++++- postprocessors/grbl_laser.py | 8 +++++++- postprocessors/line_xyz.py | 7 ++++++- postprocessors/manual_toolchange.py | 7 ++++++- postprocessors/marlin.py | 7 ++++++- 8 files changed, 60 insertions(+), 8 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index c17c211f..9799487f 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -1638,6 +1638,11 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): self.app.inform.emit("[error_notcl]Please select one or more tools from the list and try again.") return + xmin = self.options['xmin'] + ymin = self.options['ymin'] + xmax = self.options['xmax'] + ymax = self.options['ymax'] + job_name = self.options["name"] + "_cnc" pp_excellon_name = self.options["ppname_e"] @@ -1670,6 +1675,11 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): job_obj.coords_decimals = int(self.app.defaults["cncjob_coords_decimals"]) job_obj.fr_decimals = int(self.app.defaults["cncjob_fr_decimals"]) + job_obj.options['xmin'] = xmin + job_obj.options['ymin'] = ymin + job_obj.options['xmax'] = xmax + job_obj.options['ymax'] = ymax + # There could be more than one drill size... # job_obj.tooldia = # TODO: duplicate variable! # job_obj.options["tooldia"] = @@ -2952,7 +2962,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.app.report_usage("geometry_on_generatecnc_button") self.read_form() - # test to see if we have tools available in the tool table if self.ui.geo_tools_table.selectedItems(): for x in self.ui.geo_tools_table.selectedItems(): @@ -2997,6 +3006,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): segx = segx if segx is not None else float(self.app.defaults['geometry_segx']) segy = segy if segy is not None else float(self.app.defaults['geometry_segy']) + xmin = self.options['xmin'] + ymin = self.options['ymin'] + xmax = self.options['xmax'] + ymax = self.options['ymax'] + # Object initialization function for app.new_object() # RUNNING ON SEPARATE THREAD! def job_init_single_geometry(job_obj, app_obj): @@ -3126,6 +3140,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): job_obj.options['type'] = 'Geometry' job_obj.options['tool_dia'] = tooldia_val + job_obj.options['xmin'] = xmin + job_obj.options['ymin'] = ymin + job_obj.options['xmax'] = xmax + job_obj.options['ymax'] = ymax + app_obj.progress.emit(40) res = job_obj.generate_from_geometry_2( @@ -3390,6 +3409,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): :param ppname_g Name of the postprocessor :return: None """ + tooldia = tooldia if tooldia else self.options["cnctooldia"] outname = outname if outname is not None else self.options["name"] @@ -4045,7 +4065,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): preamble = str(self.ui.prepend_text.get_value()) postamble = str(self.ui.append_text.get_value()) self.app.gcode_edited = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True) - + print(self.app.gcode_edited) # first clear previous text in text editor (if any) self.app.ui.code_editor.clear() diff --git a/README.md b/README.md index a788191c..721541fe 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing. - added key shortcuts for Enable Plots, Disable Plots and Disable other plots functions (Alt+1, Alt+2, Alt+3) - hidden the snap magnet entry and snap magnet toggle from the main view; they are now active only in Editor Mode - updated the camlib.CNCJob.scale() function so now the GCode is scaled also (quite a HACK :( it will need to be replaced at some point)). Units change work now on the GCODE also. +- added the bounds coordinates to the GCODE header 30.01.2019 diff --git a/postprocessors/default.py b/postprocessors/default.py index 3f82d569..6ee5eb1b 100644 --- a/postprocessors/default.py +++ b/postprocessors/default.py @@ -42,7 +42,12 @@ class default(FlatCAMPostProc): if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry': gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' else: - gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n' + + gcode += '(X min: ' + '%.*f' % (p.coords_decimals, p['options']['xmin']) + units + ')\n' + gcode += '(Y min: ' + '%.*f' % (p.coords_decimals, p['options']['ymin']) + units + ')\n' + gcode += '(X max: ' + '%.*f' % (p.coords_decimals, p['options']['xmax']) + units + ')\n' + gcode += '(Y max: ' + '%.*f' % (p.coords_decimals, p['options']['ymax']) + units + ')\n\n' gcode += '(Spindle Speed: %s RPM)\n' % str(p['spindlespeed']) diff --git a/postprocessors/grbl_11.py b/postprocessors/grbl_11.py index c2c25398..82a9021f 100644 --- a/postprocessors/grbl_11.py +++ b/postprocessors/grbl_11.py @@ -40,7 +40,12 @@ class grbl_11(FlatCAMPostProc): if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry': gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' else: - gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n' + + gcode += '(X min: ' + '%.*f' % (p.coords_decimals, p['options']['xmin']) + units + ')\n' + gcode += '(Y min: ' + '%.*f' % (p.coords_decimals, p['options']['ymin']) + units + ')\n' + gcode += '(X max: ' + '%.*f' % (p.coords_decimals, p['options']['xmax']) + units + ')\n' + gcode += '(Y max: ' + '%.*f' % (p.coords_decimals, p['options']['ymax']) + units + ')\n\n' gcode += '(Spindle Speed: ' + str(p['spindlespeed']) + ' RPM' + ')\n' + '\n' diff --git a/postprocessors/grbl_laser.py b/postprocessors/grbl_laser.py index 9a7dd274..95b0cc5e 100644 --- a/postprocessors/grbl_laser.py +++ b/postprocessors/grbl_laser.py @@ -22,7 +22,13 @@ 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 += ('G20' if p.units.upper() == 'IN' else 'G21') + "\n" + '\n' + + gcode += '(X min: ' + '%.*f' % (p.coords_decimals, p['options']['xmin']) + units + ')\n' + gcode += '(Y min: ' + '%.*f' % (p.coords_decimals, p['options']['ymin']) + units + ')\n' + gcode += '(X max: ' + '%.*f' % (p.coords_decimals, p['options']['xmax']) + units + ')\n' + gcode += '(Y max: ' + '%.*f' % (p.coords_decimals, p['options']['ymax']) + units + ')\n\n' + gcode += 'G90\n' gcode += 'G94\n' gcode += 'G17\n' diff --git a/postprocessors/line_xyz.py b/postprocessors/line_xyz.py index 38e0daf8..6bc52ffb 100644 --- a/postprocessors/line_xyz.py +++ b/postprocessors/line_xyz.py @@ -40,7 +40,12 @@ class line_xyz(FlatCAMPostProc): if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry': gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' else: - gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n' + + gcode += '(X min: ' + '%.*f' % (p.coords_decimals, p['options']['xmin']) + units + ')\n' + gcode += '(Y min: ' + '%.*f' % (p.coords_decimals, p['options']['ymin']) + units + ')\n' + gcode += '(X max: ' + '%.*f' % (p.coords_decimals, p['options']['xmax']) + units + ')\n' + gcode += '(Y max: ' + '%.*f' % (p.coords_decimals, p['options']['ymax']) + units + ')\n\n' gcode += '(Spindle Speed: %s RPM)\n' % str(p['spindlespeed']) diff --git a/postprocessors/manual_toolchange.py b/postprocessors/manual_toolchange.py index 3a13eb52..df457bc8 100644 --- a/postprocessors/manual_toolchange.py +++ b/postprocessors/manual_toolchange.py @@ -40,7 +40,12 @@ class manual_toolchange(FlatCAMPostProc): if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry': gcode += '(Postprocessor Excellon: ' + str(p['pp_excellon_name']) + ')\n' else: - gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + gcode += '(Postprocessor Geometry: ' + str(p['pp_geometry_name']) + ')\n' + '\n' + + gcode += '(X min: ' + '%.*f' % (p.coords_decimals, p['options']['xmin']) + units + ')\n' + gcode += '(Y min: ' + '%.*f' % (p.coords_decimals, p['options']['ymin']) + units + ')\n' + gcode += '(X max: ' + '%.*f' % (p.coords_decimals, p['options']['xmax']) + units + ')\n' + gcode += '(Y max: ' + '%.*f' % (p.coords_decimals, p['options']['ymax']) + units + ')\n\n' gcode += '(Spindle Speed: %s RPM)\n' % str(p['spindlespeed']) diff --git a/postprocessors/marlin.py b/postprocessors/marlin.py index 76078b7b..d1c9e619 100644 --- a/postprocessors/marlin.py +++ b/postprocessors/marlin.py @@ -43,7 +43,12 @@ class marlin(FlatCAMPostProc): if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry': gcode += ';Postprocessor Excellon: ' + str(p['pp_excellon_name']) + '\n' else: - gcode += ';Postprocessor Geometry: ' + str(p['pp_geometry_name']) + '\n' + gcode += ';Postprocessor Geometry: ' + str(p['pp_geometry_name']) + '\n' + '\n' + + gcode += ';X min: ' + '%.*f' % (p.coords_decimals, p['options']['xmin']) + units + '\n' + gcode += ';Y min: ' + '%.*f' % (p.coords_decimals, p['options']['ymin']) + units + '\n' + gcode += ';X max: ' + '%.*f' % (p.coords_decimals, p['options']['xmax']) + units + '\n' + gcode += ';Y max: ' + '%.*f' % (p.coords_decimals, p['options']['ymax']) + units + '\n\n' gcode += ';Spindle Speed: ' + str(p['spindlespeed']) + ' RPM' + '\n' + '\n'