From 0e4eb2631e077946c0fed577605212684845b839 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Thu, 16 Dec 2021 05:33:25 +0200 Subject: [PATCH] - in Milling Plugin fixed the toolchange_xy and end_xy parameters not being used --- CHANGELOG.md | 4 ++++ FlatCAM.py | 3 +++ appEditors/AppExcEditor.py | 2 +- appPlugins/ToolMilling.py | 32 ++++++++++++++++++-------------- camlib.py | 21 ++++++++++++++++----- defaults.py | 2 +- 6 files changed, 43 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 791352a3..64439745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +16.12.2021 + +- in Milling Plugin fixed the toolchange_xy and end_xy parameters not being used + 9.12.2021 - small optimization when deleting all objects (creating a new project) diff --git a/FlatCAM.py b/FlatCAM.py index 95340601..39b4650d 100644 --- a/FlatCAM.py +++ b/FlatCAM.py @@ -11,6 +11,7 @@ from appGUI import VisPyPatches from multiprocessing import freeze_support # import copyreg # import types +# import qdarktheme MIN_VERSION_MAJOR = 3 MIN_VERSION_MINOR = 6 @@ -154,6 +155,8 @@ if __name__ == '__main__': style = QtWidgets.QStyleFactory.keys()[idx] app.setStyle(style) + # app.setStyleSheet(qdarktheme.load_stylesheet()) + fc = App(qapp=app) # interrupt the Qt loop such that Python events have a chance to be responsive diff --git a/appEditors/AppExcEditor.py b/appEditors/AppExcEditor.py index 93e8b821..27944881 100644 --- a/appEditors/AppExcEditor.py +++ b/appEditors/AppExcEditor.py @@ -2437,7 +2437,7 @@ class AppExcEditor(QtCore.QObject): for shape_exc in source_storage.get_objects(): geo_list = [] if isinstance(shape_exc.geo, MultiLineString): - for subgeo in shape_exc.geo: + for subgeo in shape_exc.geo.geoms: geo_list.append(affinity.scale(subgeo, xfact=factor, yfact=factor, origin='center')) new_geo = MultiLineString(geo_list) elif isinstance(shape_exc.geo, Polygon): diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index 6bacb593..cde64c93 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -2868,7 +2868,7 @@ class ToolMilling(AppTool, Excellon): toolchangexy = tools_dict[tooluid_key]['data']["tools_mill_toolchangexy"] startz = tools_dict[tooluid_key]['data']["tools_mill_startz"] endz = tools_dict[tooluid_key]['data']["tools_mill_endz"] - endxy = self.target_obj.options["tools_mill_endxy"] + endxy = tools_dict[tooluid_key]['data']["tools_mill_endxy"] spindlespeed = tools_dict[tooluid_key]['data']["tools_mill_spindlespeed"] dwell = tools_dict[tooluid_key]['data']["tools_mill_dwell"] dwelltime = tools_dict[tooluid_key]['data']["tools_mill_dwelltime"] @@ -2995,8 +2995,6 @@ class ToolMilling(AppTool, Excellon): # create the Paint geometry for this tool bbox = box(xmin-margin, ymin-margin, xmax+margin, ymax+margin) - print(bbox.wkt) - print(margin, overlap, paint_method) # paint the box try: @@ -3055,27 +3053,29 @@ class ToolMilling(AppTool, Excellon): # ##################################################################################################### # Toolchange Z - tools_dict[tooluid_key]['data']['toolchangez'] = self.ui.toolchangez_entry.get_value() + tools_dict[tooluid_key]['data']['tools_mill_toolchangez'] = self.ui.toolchangez_entry.get_value() + # Toolchange X-Y + tools_dict[tooluid_key]['data']['tools_mill_toolchangexy'] = self.ui.toolchangexy_entry.get_value() # End Move Z - tools_dict[tooluid_key]['data']['endz'] = self.ui.endz_entry.get_value() + tools_dict[tooluid_key]['data']['tools_mill_endz'] = self.ui.endz_entry.get_value() # End Move XY - tools_dict[tooluid_key]['data']['endxy'] = self.ui.endxy_entry.get_value() + tools_dict[tooluid_key]['data']['tools_mill_endxy'] = self.ui.endxy_entry.get_value() # Probe Z - tools_dict[tooluid_key]['data']['z_pdepth'] = self.ui.pdepth_entry.get_value() + tools_dict[tooluid_key]['data']['tools_mill_z_pdepth'] = self.ui.pdepth_entry.get_value() # Probe FR - tools_dict[tooluid_key]['data']['feedrate_probe'] = self.ui.feedrate_probe_entry.get_value() + tools_dict[tooluid_key]['data']['tools_mill_feedrate_probe'] = self.ui.feedrate_probe_entry.get_value() # Exclusion Areas Enable - tools_dict[tooluid_key]['data']['area_exclusion'] = self.ui.exclusion_cb.get_value() + tools_dict[tooluid_key]['data']['tools_mill_area_exclusion'] = self.ui.exclusion_cb.get_value() # Exclusion Areas Shape - tools_dict[tooluid_key]['data']['area_shape'] = self.ui.area_shape_radio.get_value() + tools_dict[tooluid_key]['data']['tools_mill_area_shape'] = self.ui.area_shape_radio.get_value() # Exclusion Areas Strategy - tools_dict[tooluid_key]['data']['area_strategy'] = self.ui.strategy_radio.get_value() + tools_dict[tooluid_key]['data']['tools_mill_area_strategy'] = self.ui.strategy_radio.get_value() # Exclusion Areas Overz - tools_dict[tooluid_key]['data']['area_overz'] = self.ui.over_z_entry.get_value() + tools_dict[tooluid_key]['data']['tools_mill_area_overz'] = self.ui.over_z_entry.get_value() # Preprocessor - tools_dict[tooluid_key]['data']['ppname_g'] = self.ui.pp_geo_name_cb.get_value() + tools_dict[tooluid_key]['data']['tools_mill_ppname_g'] = self.ui.pp_geo_name_cb.get_value() # Offset calculation offset_type = dia_cnc_dict['data']['tools_mill_offset_type'] @@ -3117,8 +3117,12 @@ class ToolMilling(AppTool, Excellon): tool_lst = list(tools_dict.keys()) is_first = True if tooluid_key == tool_lst[0] else False + first_pt = (0, 0) is_last = True if tooluid_key == tool_lst[-1] else False - res, start_gcode = new_cncjob_obj.geometry_tool_gcode_gen(tooluid_key, tools_dict, first_pt=(0, 0), + last_pt = tools_dict[tooluid_key]['data']['tools_mill_endxy'] + + res, start_gcode = new_cncjob_obj.geometry_tool_gcode_gen(tooluid_key, tools_dict, first_pt=first_pt, + last_pt=last_pt, tolerance=tol, is_first=is_first, is_last=is_last, toolchange=is_toolchange) diff --git a/camlib.py b/camlib.py index 89f0a856..033ce63f 100644 --- a/camlib.py +++ b/camlib.py @@ -3632,7 +3632,7 @@ class CNCjob(Geometry): return t_gcode, (locx, locy), start_gcode # used in Geometry (and soon in Tool Milling) - def geometry_tool_gcode_gen(self, tool, tools, first_pt, tolerance, is_first=False, is_last=False, + def geometry_tool_gcode_gen(self, tool, tools, first_pt, last_pt, tolerance, is_first=False, is_last=False, toolchange=False): """ Algorithm to generate GCode from multitool Geometry. @@ -3643,6 +3643,9 @@ class CNCjob(Geometry): :type tools: dict :param first_pt: a tuple of coordinates for the first point of the current tool :type first_pt: tuple + :param last_pt: a tuple of coordinates for the last point of the current tool + (which is the same for all tools) + :type last_pt: tuple :param tolerance: geometry tolerance :type tolerance: :param is_first: if the current tool is the first tool (for this we need to add start GCode) @@ -3813,7 +3816,8 @@ class CNCjob(Geometry): self.startz = None self.z_end = float(tool_dict['tools_mill_endz']) - self.xy_end = tool_dict['tools_mill_endxy'] + self.xy_end = last_pt + try: if self.xy_end == '' or self.xy_end is None: self.xy_end = None @@ -3829,7 +3833,7 @@ class CNCjob(Geometry): self.app.inform.emit('[ERROR] %s' % _("The End X,Y format has to be (x, y).")) return 'fail' except Exception as e: - log.error("camlib.CNCJob.geometry_from_excellon_by_tool() xy_end --> %s" % str(e)) + log.error("camlib.CNCJob.geometry_tool_gcode_gen xy_end --> %s" % str(e)) self.xy_end = [0, 0] self.z_toolchange = tool_dict['tools_mill_toolchangez'] @@ -3966,7 +3970,7 @@ class CNCjob(Geometry): log.warning("Number of paths for which to generate GCode: %s" % str(geo_len)) old_disp_number = 0 - current_pt = (0, 0) + current_pt = first_pt for pt, geo in optimized_path: if self.app.abort_flag: # graceful abort requested by the user @@ -4025,7 +4029,14 @@ class CNCjob(Geometry): if is_last: t_gcode += self.doformat(p.spindle_stop_code) t_gcode += self.doformat(p.lift_code, x=current_pt[0], y=current_pt[1]) - t_gcode += self.doformat(p.end_code, x=0, y=0) + if isinstance(self.xy_end, tuple): + endx = self.xy_end[0] + endy = self.xy_end[1] + else: + endx = 0 + endy = 0 + + t_gcode += self.doformat(p.end_code, x=endx, y=endy) self.app.inform.emit( '%s... %s %s.' % (_("Finished G-Code generation"), str(path_count), _("paths traced")) ) diff --git a/defaults.py b/defaults.py index 9f4094b3..f6dc3237 100644 --- a/defaults.py +++ b/defaults.py @@ -450,9 +450,9 @@ class FlatCAMDefaults: "tools_mill_extracut": False, "tools_mill_extracut_length": 0.1, "tools_mill_z_pdepth": -0.02, + "tools_mill_feedrate_probe": 75, "tools_mill_f_plunge": False, "tools_mill_spindledir": 'CW', - "tools_mill_feedrate_probe": 75, "tools_mill_area_exclusion": False, "tools_mill_area_shape": "polygon",