From aac4fd75ca46ad61eec573c05e3d33b5bcce7223 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 24 Nov 2019 04:21:18 +0200 Subject: [PATCH] - small fixes --- FlatCAMObj.py | 22 ++++----- camlib.py | 74 ++++++++++++++++++------------ flatcamTools/ToolCopperThieving.py | 9 ++-- flatcamTools/ToolFiducials.py | 9 +++- 4 files changed, 66 insertions(+), 48 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index fd7bf0d0..8f20afd1 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -6367,14 +6367,13 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): if 'M6' in g: m6_code = self.parse_custom_toolchange_code(self.ui.toolchange_text.get_value()) if m6_code is None or m6_code == '': - self.app.inform.emit('[ERROR_NOTCL] %s' % - _("Cancelled. The Toolchange Custom code is enabled but it's empty.") - ) + self.app.inform.emit( + '[ERROR_NOTCL] %s' % _("Cancelled. The Toolchange Custom code is enabled but it's empty.") + ) return 'fail' g = g.replace('M6', m6_code) - self.app.inform.emit('[success] %s' % - _("Toolchange G-code was replaced by a custom code.")) + self.app.inform.emit('[success] %s' % _("Toolchange G-code was replaced by a custom code.")) lines = StringIO(g) @@ -6391,13 +6390,13 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): for line in lines: f.write(line) except FileNotFoundError: - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("No such file or directory")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("No such file or directory")) return except PermissionError: - self.app.inform.emit('[WARNING] %s' % - _("Permission denied, saving not possible.\n" - "Most likely another app is holding the file open and not accessible.")) + self.app.inform.emit( + '[WARNING] %s' % _("Permission denied, saving not possible.\n" + "Most likely another app is holding the file open and not accessible.") + ) return 'fail' elif to_file is False: # Just for adding it to the recent files list. @@ -6405,8 +6404,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): self.app.file_opened.emit("cncjob", filename) self.app.file_saved.emit("cncjob", filename) - self.app.inform.emit('[success] %s: %s' % - (_("Saved to"), filename)) + self.app.inform.emit('[success] %s: %s' % (_("Saved to"), filename)) else: return lines diff --git a/camlib.py b/camlib.py index b794dfe6..9212d5cd 100644 --- a/camlib.py +++ b/camlib.py @@ -2956,13 +2956,14 @@ class CNCjob(Geometry): self.app.inform.emit(_("Finished G-Code generation...")) return 'OK' - def generate_from_multitool_geometry(self, geometry, append=True, - tooldia=None, offset=0.0, tolerance=0, z_cut=1.0, z_move=2.0, - feedrate=2.0, feedrate_z=2.0, feedrate_rapid=30, - spindlespeed=None, spindledir='CW', dwell=False, dwelltime=1.0, - multidepth=False, depthpercut=None, - toolchange=False, toolchangez=1.0, toolchangexy="0.0, 0.0", extracut=False, - startz=None, endz=2.0, pp_geometry_name=None, tool_no=1): + def generate_from_multitool_geometry( + self, geometry, append=True, + tooldia=None, offset=0.0, tolerance=0, z_cut=1.0, z_move=2.0, + feedrate=2.0, feedrate_z=2.0, feedrate_rapid=30, + spindlespeed=None, spindledir='CW', dwell=False, dwelltime=1.0, + multidepth=False, depthpercut=None, + toolchange=False, toolchangez=1.0, toolchangexy="0.0, 0.0", extracut=False, + startz=None, endz=2.0, pp_geometry_name=None, tool_no=1): """ Algorithm to generate from multitool Geometry. @@ -2973,13 +2974,29 @@ class CNCjob(Geometry): :param geometry: :param append: :param tooldia: + :param offset: :param tolerance: - :param multidepth: If True, use multiple passes to reach - the desired depth. - :param depthpercut: Maximum depth in each pass. - :param extracut: Adds (or not) an extra cut at the end of each path - overlapping the first point in path to ensure complete copper removal - :return: GCode - string + :param z_cut: + :param z_move: + :param feedrate: + :param feedrate_z: + :param feedrate_rapid: + :param spindlespeed: + :param spindledir: + :param dwell: + :param dwelltime: + :param multidepth: If True, use multiple passes to reach the desired depth. + :param depthpercut: Maximum depth in each pass. + :param toolchange: + :param toolchangez: + :param toolchangexy: + :param extracut: Adds (or not) an extra cut at the end of each path overlapping the + first point in path to ensure complete copper removal + :param startz: + :param endz: + :param pp_geometry_name: + :param tool_no: + :return: GCode - string """ log.debug("Generate_from_multitool_geometry()") @@ -3063,17 +3080,16 @@ class CNCjob(Geometry): return 'fail' if self.z_move is None: - self.app.inform.emit('[ERROR_NOTCL] %s' % - _("Travel Z parameter is None or zero.")) + self.app.inform.emit('[ERROR_NOTCL] %s' % _("Travel Z parameter is None or zero.")) return 'fail' if self.z_move < 0: self.app.inform.emit('[WARNING] %s' % _("The Travel Z parameter has negative value. " - "It is the height value to travel between cuts.\n" - "The Z Travel parameter needs to have a positive value, assuming it is a typo " - "therefore the app will convert the value to positive." - "Check the resulting CNC code (Gcode etc).")) + "It is the height value to travel between cuts.\n" + "The Z Travel parameter needs to have a positive value, assuming it is a typo " + "therefore the app will convert the value to positive." + "Check the resulting CNC code (Gcode etc).")) self.z_move = -self.z_move elif self.z_move == 0: self.app.inform.emit('[WARNING] %s: %s' % @@ -3164,7 +3180,7 @@ class CNCjob(Geometry): # variables to display the percentage of work done geo_len = len(flat_geometry) - disp_number = 0 + old_disp_number = 0 log.warning("Number of paths for which to generate GCode: %s" % str(geo_len)) @@ -3173,11 +3189,9 @@ class CNCjob(Geometry): else: current_tooldia = float('%.4f' % float(self.tooldia)) - self.app.inform.emit( - '%s: %s%s.' % (_("Starting G-Code for tool with diameter"), - str(current_tooldia), - str(self.units)) - ) + self.app.inform.emit( '%s: %s%s.' % (_("Starting G-Code for tool with diameter"), + str(current_tooldia), + str(self.units))) pt, geo = storage.nearest(current_pt) @@ -3223,7 +3237,7 @@ class CNCjob(Geometry): total_travel = total_travel + abs(distance(pt1=current_pt, pt2=pt)) current_pt = geo.coords[-1] - pt, geo = storage.nearest(current_pt) # Next + pt, geo = storage.nearest(current_pt) # Next disp_number = int(np.interp(path_count, [0, geo_len], [0, 100])) if old_disp_number < disp_number <= 100: @@ -3288,11 +3302,11 @@ class CNCjob(Geometry): # if solid_geometry is empty raise an exception if not geometry.solid_geometry: - self.app.inform.emit('[ERROR_NOTCL] %s' % - _("Trying to generate a CNC Job " - "from a Geometry object without solid_geometry.")) + self.app.inform.emit( + '[ERROR_NOTCL] %s' % _("Trying to generate a CNC Job from a Geometry object without solid_geometry.") + ) - temp_solid_geometry = [] + temp_solid_geometry = list() def bounds_rec(obj): if type(obj) is list: diff --git a/flatcamTools/ToolCopperThieving.py b/flatcamTools/ToolCopperThieving.py index 5c55ffd2..62276f42 100644 --- a/flatcamTools/ToolCopperThieving.py +++ b/flatcamTools/ToolCopperThieving.py @@ -127,7 +127,7 @@ class ToolCopperThieving(FlatCAMTool): ], orientation='vertical', stretch=False) self.reference_label = QtWidgets.QLabel(_("Reference:")) self.reference_label.setToolTip( - _("- 'Itself' - the copper thieving extent is based on the object that is copper cleared.\n " + _("- 'Itself' - the copper thieving extent is based on the object that is copper cleared.\n" "- 'Area Selection' - left mouse click to start selection of the area to be filled.\n" "- 'Reference Object' - will do copper thieving within the area specified by another object.") ) @@ -171,7 +171,7 @@ class ToolCopperThieving(FlatCAMTool): ], stretch=False) self.bbox_type_label = QtWidgets.QLabel(_("Box Type:")) self.bbox_type_label.setToolTip( - _("- 'Rectangular' - the bounding box will be of rectangular shape.\n " + _("- 'Rectangular' - the bounding box will be of rectangular shape.\n" "- 'Minimal' - the bounding box will be the convex hull shape.") ) grid_lay.addWidget(self.bbox_type_label, 6, 0) @@ -193,7 +193,7 @@ class ToolCopperThieving(FlatCAMTool): ], orientation='vertical', stretch=False) self.fill_type_label = QtWidgets.QLabel(_("Fill Type:")) self.fill_type_label.setToolTip( - _("- 'Solid' - copper thieving will be a solid polygon.\n " + _("- 'Solid' - copper thieving will be a solid polygon.\n" "- 'Dots Grid' - the empty area will be filled with a pattern of dots.\n" "- 'Squares Grid' - the empty area will be filled with a pattern of squares.\n" "- 'Lines Grid' - the empty area will be filled with a pattern of lines.") @@ -412,10 +412,11 @@ class ToolCopperThieving(FlatCAMTool): self.geo_steps_per_circle = 128 # SIGNALS - self.fill_button.clicked.connect(self.execute) self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type) self.reference_radio.group_toggle_fn = self.on_toggle_reference self.fill_type_radio.activated_custom.connect(self.on_thieving_type) + + self.fill_button.clicked.connect(self.execute) self.rb_button.clicked.connect(self.add_robber_bar) def run(self, toggle=True): diff --git a/flatcamTools/ToolFiducials.py b/flatcamTools/ToolFiducials.py index 26ca9add..20e29872 100644 --- a/flatcamTools/ToolFiducials.py +++ b/flatcamTools/ToolFiducials.py @@ -425,6 +425,8 @@ class ToolFiducials(FlatCAMTool): self.sec_position = self.pos_radio.get_value() fid_type = self.fid_type_radio.get_value() + self.click_points = list() + # get the Gerber object on which the Fiducial will be inserted selection_index = self.grb_object_combo.currentIndex() model_index = self.app.collection.index(selection_index, 0, self.grb_object_combo.rootModelIndex()) @@ -756,11 +758,14 @@ class ToolFiducials(FlatCAMTool): elif len(self.click_points) == 3: self.sec_points_coords_entry.set_value(self.click_points[2]) self.app.inform.emit('[success] %s' % _("Done. All fiducials have been added.")) - self.add_fiducials_geo(self.click_points) + self.add_fiducials_geo(self.click_points, g_obj=self.grb_object, fid_type=fid_type) + self.grb_object.source_file = self.app.export_gerber(obj_name=self.grb_object.options['name'], + filename=None, + local_use=self.grb_object, use_thread=False) self.on_exit() else: if len(self.click_points) == 2: - self.sec_points_coords_entry.set_value(self.click_points[2]) + self.top_right_coords_entry.set_value(self.click_points[1]) self.app.inform.emit('[success] %s' % _("Done. All fiducials have been added.")) self.add_fiducials_geo(self.click_points, g_obj=self.grb_object, fid_type=fid_type) self.grb_object.source_file = self.app.export_gerber(obj_name=self.grb_object.options['name'],