Ver Fonte

- fixed a cummulative error when using the Tool Offset for Excellon objects
- added the dipaly of the real depth of cut (cut z + offset_z) for CNC tools made out of an Excellon object

Marius Stanciu há 6 anos atrás
pai
commit
621ac9a598
4 ficheiros alterados com 31 adições e 14 exclusões
  1. 9 5
      FlatCAMObj.py
  2. 2 0
      README.md
  3. 17 7
      camlib.py
  4. 3 2
      flatcamGUI/ObjectUI.py

+ 9 - 5
FlatCAMObj.py

@@ -2206,10 +2206,10 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
         })
         })
 
 
         # TODO: Document this.
         # TODO: Document this.
-        self.tool_cbs = {}
+        self.tool_cbs = dict()
 
 
         # dict to hold the tool number as key and tool offset as value
         # dict to hold the tool number as key and tool offset as value
-        self.tool_offset = {}
+        self.tool_offset = dict()
 
 
         # variable to store the total amount of drills per job
         # variable to store the total amount of drills per job
         self.tot_drill_cnt = 0
         self.tot_drill_cnt = 0
@@ -6168,11 +6168,13 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
             dia_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, float(tooldia_key)))
             dia_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, float(tooldia_key)))
             nr_drills_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_drills']))
             nr_drills_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_drills']))
             nr_slots_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_slots']))
             nr_slots_item = QtWidgets.QTableWidgetItem('%d' % int(dia_value['nr_slots']))
+            cutz_item = QtWidgets.QTableWidgetItem('%.*f' % (self.decimals, float(dia_value['offset_z']) + self.z_cut))
 
 
             id.setFlags(QtCore.Qt.ItemIsEnabled)
             id.setFlags(QtCore.Qt.ItemIsEnabled)
             dia_item.setFlags(QtCore.Qt.ItemIsEnabled)
             dia_item.setFlags(QtCore.Qt.ItemIsEnabled)
             nr_drills_item.setFlags(QtCore.Qt.ItemIsEnabled)
             nr_drills_item.setFlags(QtCore.Qt.ItemIsEnabled)
             nr_slots_item.setFlags(QtCore.Qt.ItemIsEnabled)
             nr_slots_item.setFlags(QtCore.Qt.ItemIsEnabled)
+            cutz_item.setFlags(QtCore.Qt.ItemIsEnabled)
 
 
             # hack so the checkbox stay centered in the table cell
             # hack so the checkbox stay centered in the table cell
             # used this:
             # used this:
@@ -6201,7 +6203,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
 
 
             # ## REMEMBER: THIS COLUMN IS HIDDEN IN OBJECTUI.PY # ##
             # ## REMEMBER: THIS COLUMN IS HIDDEN IN OBJECTUI.PY # ##
             self.ui.exc_cnc_tools_table.setItem(row_no, 4, tool_uid_item)  # Tool unique ID)
             self.ui.exc_cnc_tools_table.setItem(row_no, 4, tool_uid_item)  # Tool unique ID)
-            self.ui.exc_cnc_tools_table.setCellWidget(row_no, 5, plot_item)
+            self.ui.exc_cnc_tools_table.setItem(row_no, 5, cutz_item)
+            self.ui.exc_cnc_tools_table.setCellWidget(row_no, 6, plot_item)
 
 
         for row in range(tool_idx):
         for row in range(tool_idx):
             self.ui.exc_cnc_tools_table.item(row, 0).setFlags(
             self.ui.exc_cnc_tools_table.item(row, 0).setFlags(
@@ -6222,14 +6225,15 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         horizontal_header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
         horizontal_header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
         horizontal_header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
         horizontal_header.setSectionResizeMode(2, QtWidgets.QHeaderView.ResizeToContents)
         horizontal_header.setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents)
         horizontal_header.setSectionResizeMode(3, QtWidgets.QHeaderView.ResizeToContents)
+        horizontal_header.setSectionResizeMode(5, QtWidgets.QHeaderView.ResizeToContents)
 
 
-        horizontal_header.setSectionResizeMode(5, QtWidgets.QHeaderView.Fixed)
+        horizontal_header.setSectionResizeMode(6, QtWidgets.QHeaderView.Fixed)
 
 
         # horizontal_header.setStretchLastSection(True)
         # horizontal_header.setStretchLastSection(True)
         self.ui.exc_cnc_tools_table.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
         self.ui.exc_cnc_tools_table.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
 
 
         self.ui.exc_cnc_tools_table.setColumnWidth(0, 20)
         self.ui.exc_cnc_tools_table.setColumnWidth(0, 20)
-        self.ui.exc_cnc_tools_table.setColumnWidth(5, 17)
+        self.ui.exc_cnc_tools_table.setColumnWidth(6, 17)
 
 
         self.ui.exc_cnc_tools_table.setMinimumHeight(self.ui.exc_cnc_tools_table.getHeight())
         self.ui.exc_cnc_tools_table.setMinimumHeight(self.ui.exc_cnc_tools_table.getHeight())
         self.ui.exc_cnc_tools_table.setMaximumHeight(self.ui.exc_cnc_tools_table.getHeight())
         self.ui.exc_cnc_tools_table.setMaximumHeight(self.ui.exc_cnc_tools_table.getHeight())

+ 2 - 0
README.md

@@ -16,6 +16,8 @@ CAD program, and create G-Code for Isolation routing.
 - if extracut_length is zero then the extracut will cut up until the first point in path no matter what the distance is
 - if extracut_length is zero then the extracut will cut up until the first point in path no matter what the distance is
 - in Gerber isolation, when selection mode is checked, now area selection works too
 - in Gerber isolation, when selection mode is checked, now area selection works too
 - in CNCJob UI, now the CNCJob objects made out of Excellon objects will display their CNC tools (drill bits)
 - in CNCJob UI, now the CNCJob objects made out of Excellon objects will display their CNC tools (drill bits)
+- fixed a cummulative error when using the Tool Offset for Excellon objects
+- added the dipaly of the real depth of cut (cut z + offset_z) for CNC tools made out of an Excellon object
 
 
 9.12.2019 
 9.12.2019 
 
 

+ 17 - 7
camlib.py

@@ -2158,7 +2158,7 @@ class CNCjob(Geometry):
         self.units = units
         self.units = units
 
 
         self.z_cut = z_cut
         self.z_cut = z_cut
-        self.tool_offset = {}
+        self.tool_offset = dict()
 
 
         self.z_move = z_move
         self.z_move = z_move
 
 
@@ -2359,7 +2359,9 @@ class CNCjob(Geometry):
         self.exc_drills = deepcopy(exobj.drills)
         self.exc_drills = deepcopy(exobj.drills)
         self.exc_tools = deepcopy(exobj.tools)
         self.exc_tools = deepcopy(exobj.tools)
 
 
-        self.z_cut = drillz
+        self.z_cut = deepcopy(drillz)
+        old_zcut = deepcopy(drillz)
+
         if self.machinist_setting == 0:
         if self.machinist_setting == 0:
             if drillz > 0:
             if drillz > 0:
                 self.app.inform.emit('[WARNING] %s' %
                 self.app.inform.emit('[WARNING] %s' %
@@ -2441,10 +2443,16 @@ class CNCjob(Geometry):
                                 LineString([start, stop]).buffer((it[1] / 2.0), resolution=self.geo_steps_per_circle)
                                 LineString([start, stop]).buffer((it[1] / 2.0), resolution=self.geo_steps_per_circle)
                             )
                             )
 
 
+                    try:
+                        z_off = float(self.tool_offset[it[1]]) * (-1)
+                    except KeyError:
+                        z_off = 0
+
                     self.exc_cnc_tools[it[1]] = dict()
                     self.exc_cnc_tools[it[1]] = dict()
                     self.exc_cnc_tools[it[1]]['tool'] = it[0]
                     self.exc_cnc_tools[it[1]]['tool'] = it[0]
                     self.exc_cnc_tools[it[1]]['nr_drills'] = drill_no
                     self.exc_cnc_tools[it[1]]['nr_drills'] = drill_no
                     self.exc_cnc_tools[it[1]]['nr_slots'] = slot_no
                     self.exc_cnc_tools[it[1]]['nr_slots'] = slot_no
+                    self.exc_cnc_tools[it[1]]['offset_z'] = z_off
                     self.exc_cnc_tools[it[1]]['solid_geometry'] = deepcopy(sol_geo)
                     self.exc_cnc_tools[it[1]]['solid_geometry'] = deepcopy(sol_geo)
 
 
         self.app.inform.emit(_("Creating a list of points to drill..."))
         self.app.inform.emit(_("Creating a list of points to drill..."))
@@ -2635,7 +2643,7 @@ class CNCjob(Geometry):
                                 z_offset = float(self.tool_offset[current_tooldia]) * (-1)
                                 z_offset = float(self.tool_offset[current_tooldia]) * (-1)
                             except KeyError:
                             except KeyError:
                                 z_offset = 0
                                 z_offset = 0
-                            self.z_cut += z_offset
+                            self.z_cut = z_offset + old_zcut
 
 
                             self.coordinates_type = self.app.defaults["cncjob_coords_type"]
                             self.coordinates_type = self.app.defaults["cncjob_coords_type"]
                             if self.coordinates_type == "G90":
                             if self.coordinates_type == "G90":
@@ -2682,11 +2690,11 @@ class CNCjob(Geometry):
                             else:
                             else:
                                 self.app.inform.emit('[ERROR_NOTCL] %s...' % _('G91 coordinates not implemented'))
                                 self.app.inform.emit('[ERROR_NOTCL] %s...' % _('G91 coordinates not implemented'))
                                 return 'fail'
                                 return 'fail'
+                        self.z_cut = deepcopy(old_zcut)
                 else:
                 else:
                     log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
                     log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
                               "The loaded Excellon file has no drills ...")
                               "The loaded Excellon file has no drills ...")
-                    self.app.inform.emit('[ERROR_NOTCL] %s...' %
-                                         _('The loaded Excellon file has no drills'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s...' % _('The loaded Excellon file has no drills'))
                     return 'fail'
                     return 'fail'
 
 
                 log.debug("The total travel distance with OR-TOOLS Metaheuristics is: %s" % str(measured_distance))
                 log.debug("The total travel distance with OR-TOOLS Metaheuristics is: %s" % str(measured_distance))
@@ -2778,7 +2786,7 @@ class CNCjob(Geometry):
                                 z_offset = float(self.tool_offset[current_tooldia]) * (-1)
                                 z_offset = float(self.tool_offset[current_tooldia]) * (-1)
                             except KeyError:
                             except KeyError:
                                 z_offset = 0
                                 z_offset = 0
-                            self.z_cut += z_offset
+                            self.z_cut = z_offset + old_zcut
 
 
                             self.coordinates_type = self.app.defaults["cncjob_coords_type"]
                             self.coordinates_type = self.app.defaults["cncjob_coords_type"]
                             if self.coordinates_type == "G90":
                             if self.coordinates_type == "G90":
@@ -2825,6 +2833,7 @@ class CNCjob(Geometry):
                             else:
                             else:
                                 self.app.inform.emit('[ERROR_NOTCL] %s...' % _('G91 coordinates not implemented'))
                                 self.app.inform.emit('[ERROR_NOTCL] %s...' % _('G91 coordinates not implemented'))
                                 return 'fail'
                                 return 'fail'
+                        self.z_cut = deepcopy(old_zcut)
                 else:
                 else:
                     log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
                     log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
                               "The loaded Excellon file has no drills ...")
                               "The loaded Excellon file has no drills ...")
@@ -2879,7 +2888,7 @@ class CNCjob(Geometry):
                             z_offset = float(self.tool_offset[current_tooldia]) * (-1)
                             z_offset = float(self.tool_offset[current_tooldia]) * (-1)
                         except KeyError:
                         except KeyError:
                             z_offset = 0
                             z_offset = 0
-                        self.z_cut += z_offset
+                        self.z_cut = z_offset + old_zcut
 
 
                         self.coordinates_type = self.app.defaults["cncjob_coords_type"]
                         self.coordinates_type = self.app.defaults["cncjob_coords_type"]
                         if self.coordinates_type == "G90":
                         if self.coordinates_type == "G90":
@@ -2933,6 +2942,7 @@ class CNCjob(Geometry):
                         self.app.inform.emit('[ERROR_NOTCL] %s...' %
                         self.app.inform.emit('[ERROR_NOTCL] %s...' %
                                              _('The loaded Excellon file has no drills'))
                                              _('The loaded Excellon file has no drills'))
                         return 'fail'
                         return 'fail'
+                self.z_cut = deepcopy(old_zcut)
             log.debug("The total travel distance with Travelling Salesman Algorithm is: %s" % str(measured_distance))
             log.debug("The total travel distance with Travelling Salesman Algorithm is: %s" % str(measured_distance))
 
 
         gcode += self.doformat(p.spindle_stop_code)  # Spindle stop
         gcode += self.doformat(p.spindle_stop_code)  # Spindle stop

+ 3 - 2
flatcamGUI/ObjectUI.py

@@ -1853,9 +1853,10 @@ class CNCObjectUI(ObjectUI):
         self.exc_cnc_tools_table = FCTable()
         self.exc_cnc_tools_table = FCTable()
         self.custom_box.addWidget(self.exc_cnc_tools_table)
         self.custom_box.addWidget(self.exc_cnc_tools_table)
 
 
-        self.exc_cnc_tools_table.setColumnCount(6)
+        self.exc_cnc_tools_table.setColumnCount(7)
         self.exc_cnc_tools_table.setColumnWidth(0, 20)
         self.exc_cnc_tools_table.setColumnWidth(0, 20)
-        self.exc_cnc_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Drills'), _('Slots'), '', _('P')])
+        self.exc_cnc_tools_table.setHorizontalHeaderLabels(['#', _('Dia'), _('Drills'), _('Slots'), '', _("Cut Z"),
+                                                            _('P')])
         self.exc_cnc_tools_table.setColumnHidden(4, True)
         self.exc_cnc_tools_table.setColumnHidden(4, True)
 
 
         self.tooldia_entry = FCDoubleSpinner()
         self.tooldia_entry = FCDoubleSpinner()