فهرست منبع

- added the bounds coordinates to the GCODE header; modified the postprocessor files to show them.

Marius Stanciu 7 سال پیش
والد
کامیت
d45d2c05ec

+ 22 - 2
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()
 

+ 1 - 0
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
 

+ 6 - 1
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'])
 

+ 6 - 1
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'
 

+ 7 - 1
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'

+ 6 - 1
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'])
 

+ 6 - 1
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'])
 

+ 6 - 1
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'