瀏覽代碼

- when saving HPGL code it will be saved as a file with extension .plt
- the units mentioned in HPGL format are only METRIC therefore if FlatCAM units are in INCH they will be transform to METRIC
- the minimum unit in HPGL is 0.025mm therefore the coordinates are rounded to a multiple of 0.025mm

Marius Stanciu 7 年之前
父節點
當前提交
b9a062a84e
共有 3 個文件被更改,包括 26 次插入7 次删除
  1. 7 4
      FlatCAMObj.py
  2. 3 0
      README.md
  3. 16 3
      postprocessors/hpgl.py

+ 7 - 4
FlatCAMObj.py

@@ -3798,21 +3798,24 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         if 'Roland' in self.pp_excellon_name or 'Roland' in self.pp_geometry_name:
             _filter_ = "RML1 Files (*.rol);;" \
                        "All Files (*.*)"
+        elif 'hpgl' in self.pp_geometry_name:
+            _filter_ = "HPGL Files (*.plt);;" \
+                       "All Files (*.*)"
         else:
             _filter_ = "G-Code Files (*.nc);;G-Code Files (*.txt);;G-Code Files (*.tap);;G-Code Files (*.cnc);;" \
                        "G-Code Files (*.g-code);;All Files (*.*)"
         try:
             filename = str(QtWidgets.QFileDialog.getSaveFileName(
-                caption="Export G-Code ...", directory=self.app.get_last_save_folder(), filter=_filter_)[0])
+                caption="Export Machine Code ...", directory=self.app.get_last_save_folder(), filter=_filter_)[0])
         except TypeError:
-            filename = str(QtWidgets.QFileDialog.getSaveFileName(caption="Export G-Code ...", filter=_filter_)[0])
+            filename = str(QtWidgets.QFileDialog.getSaveFileName(caption="Export Machine Code ...", filter=_filter_)[0])
 
         preamble = str(self.ui.prepend_text.get_value())
         postamble = str(self.ui.append_text.get_value())
 
         self.export_gcode(filename, preamble=preamble, postamble=postamble)
         self.app.file_saved.emit("gcode", filename)
-        self.app.inform.emit("[success] G-Code file saved to: %s" % filename)
+        self.app.inform.emit("[success] Machine Code file saved to: %s" % filename)
 
     def on_modifygcode_button_click(self, *args):
         # add the tab if it was closed
@@ -3883,7 +3886,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
                     (str(self.app.version), str(self.app.version_date)) + '";\n'
 
             gcode += 'CO "Name: ' + str(self.options['name']) + '";\n'
-            gcode += 'CO "Type: ' + "G-code from " + str(self.options['type']) + '";\n'
+            gcode += 'CO "Type: ' + "HPGL code from " + str(self.options['type']) + '";\n'
 
             # if str(p['options']['type']) == 'Excellon' or str(p['options']['type']) == 'Excellon Geometry':
             #     gcode += '(Tools in use: ' + str(p['options']['Tools_in_use']) + ')\n'

+ 3 - 0
README.md

@@ -15,6 +15,9 @@ CAD program, and create G-Code for Isolation routing.
 - fixed the message box layout when asking to save the current work
 - made sure that whenever the HPGL postprocessor is selected the Toolchange is always ON and the MultiDepth is OFF
 - the HPGL postprocessor entry is not allowed in Excellon Object postprocessor selection combobox as it is only applicable for Geometry
+- when saving HPGL code it will be saved as a file with extension .plt
+- the units mentioned in HPGL format are only METRIC therefore if FlatCAM units are in INCH they will be transform to METRIC
+- the minimum unit in HPGL is 0.025mm therefore the coordinates are rounded to a multiple of 0.025mm
 
 19.01.2019
 

+ 16 - 3
postprocessors/hpgl.py

@@ -6,8 +6,6 @@ from FlatCAMPostProc import *
 class hpgl(FlatCAMPostProc):
 
     coordinate_format = "%.*f"
-    feedrate_format = '%.1f'
-    feedrate_rapid_format = '%.1f'
 
     def start_code(self, p):
         gcode = 'IN;'
@@ -31,8 +29,23 @@ class hpgl(FlatCAMPostProc):
         return ''
 
     def position_code(self, p):
+        units = str(p['units']).lower()
+
+        # we work only with METRIC units because HPGL mention only metric units so if FlatCAM units are INCH we
+        # transform them in METRIC
+        if units == 'in':
+            x = p.x * 25.4
+            y = p.y * 25.4
+        else:
+            x = p.x
+            y = p.y
+
+        # we need to have the coordinates as multiples of 0.025mm
+        x = round(x / 0.025) * 25 / 1000
+        y = round(y / 0.025) * 25 / 1000
+
         return ('PA' + self.coordinate_format + ',' + self.coordinate_format + ';') % \
-               (p.coords_decimals, p.x, p.coords_decimals, p.y)
+               (p.coords_decimals, x, p.coords_decimals, y)
 
     def rapid_code(self, p):
         return self.position_code(p).format(**p)