diff --git a/FlatCAMObj.py b/FlatCAMObj.py index bfb2d5b5..f9123c58 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -1076,6 +1076,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): self.tot_slot_cnt = 0 self.tool_row_slots = 0 + # variable to store the distance travelled + self.travel_distance = 0.0 + self.multigeo = False @staticmethod @@ -4523,6 +4526,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): ''' self.exc_cnc_tools = {} + # for now it show if the plot will be done for multi-tool CNCJob (True) or for single tool # (like the one in the TCL Command), False self.multitool = False @@ -4682,6 +4686,18 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): # Fill form fields only on object create self.to_form() + # this means that the object that created this CNCJob was an Excellon + try: + if self.travel_distance: + self.ui.t_distance_label.show() + self.ui.t_distance_entry.setVisible(True) + self.ui.t_distance_entry.setDisabled(True) + self.ui.t_distance_entry.set_value('%.4f' % float(self.travel_distance)) + self.ui.units_label.setText(str(self.units).lower()) + self.ui.units_label.setDisabled(True) + except AttributeError: + pass + # set the kind of geometries are plotted by default with plot2() from camlib.CNCJob self.ui.cncplot_method_combo.set_value(self.app.defaults["cncjob_plot_kind"]) diff --git a/ObjectUI.py b/ObjectUI.py index 5fe03193..1dc9074e 100644 --- a/ObjectUI.py +++ b/ObjectUI.py @@ -1199,7 +1199,7 @@ class CNCObjectUI(ObjectUI): self.plot_options_label = QtWidgets.QLabel("Plot Options:") self.custom_box.addWidget(self.plot_options_label) - self.cncplot_method_label = QtWidgets.QLabel("Plot kind:") + self.cncplot_method_label = QtWidgets.QLabel("Plot kind:") self.cncplot_method_label.setToolTip( "This selects the kind of geometries on the canvas to plot.\n" "Those can be either of type 'Travel' which means the moves\n" @@ -1222,6 +1222,18 @@ class CNCObjectUI(ObjectUI): self.name_hlay.addWidget(name_label) self.name_hlay.addWidget(self.name_entry) + self.t_distance_label = QtWidgets.QLabel("Travelled dist.:") + self.t_distance_label.setToolTip( + "This is the total travelled distance on X-Y plane.\n" + "In current units." + ) + self.t_distance_entry = FCEntry() + self.t_distance_entry.setToolTip( + "This is the total travelled distance on X-Y plane.\n" + "In current units." + ) + self.units_label = QtWidgets.QLabel() + f_lay = QtWidgets.QGridLayout() f_lay.setColumnStretch(1, 1) f_lay.setColumnStretch(2, 1) @@ -1230,6 +1242,12 @@ class CNCObjectUI(ObjectUI): f_lay.addWidget(self.cncplot_method_label, 0, 0) f_lay.addWidget(self.cncplot_method_combo, 0, 1) f_lay.addWidget(QtWidgets.QLabel(''), 0, 2) + f_lay.addWidget(self.t_distance_label, 1, 0) + f_lay.addWidget(self.t_distance_entry, 1, 1) + f_lay.addWidget(self.units_label, 1, 2) + + self.t_distance_label.hide() + self.t_distance_entry.setVisible(False) e1_lbl = QtWidgets.QLabel('') self.custom_box.addWidget(e1_lbl) diff --git a/README.md b/README.md index 9d8d3adc..98388ed0 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +14.02.2019 + +- added total travel distance for CNCJob object created from Excellon Object in the CNCJob Selected tab + 13.02.2019 - added new parameter for Excellon Object in Preferences: Fast Retract. If the checkbox is checked then after reaching the drill depth, the drill bit will be raised out of the hole asap. diff --git a/camlib.py b/camlib.py index ed568ae1..48fad505 100644 --- a/camlib.py +++ b/camlib.py @@ -4946,6 +4946,8 @@ class CNCjob(Geometry): measured_distance += abs(distance_euclidian(self.oldx, self.oldy, 0, 0)) log.debug("The total travel distance including travel to end position is: %s" % str(measured_distance) + '\n') + self.travel_distance = measured_distance + self.gcode = gcode return 'OK' @@ -5558,7 +5560,7 @@ class CNCjob(Geometry): return "fail" gobj = self.codes_split(line) - print(gobj) + ## Units if 'G' in gobj and (gobj['G'] == 20.0 or gobj['G'] == 21.0): self.units = {20.0: "IN", 21.0: "MM"}[gobj['G']]