From dc61e6fede999f2457ba4e4108f4d56cb68311c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Mon, 12 Aug 2019 21:51:25 +0200 Subject: [PATCH 1/8] Bugfix: TclCommandMillHoles was not working at all --- tclCommands/TclCommandMillHoles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tclCommands/TclCommandMillHoles.py b/tclCommands/TclCommandMillHoles.py index 38fc222b..8826f856 100644 --- a/tclCommands/TclCommandMillHoles.py +++ b/tclCommands/TclCommandMillHoles.py @@ -82,7 +82,7 @@ class TclCommandMillHoles(TclCommandSignaled): del args['name'] # This runs in the background... Is blocking handled? - success, msg = obj.generate_milling(**args) + success, msg = obj.generate_milling_drills(**args) except Exception as e: self.raise_tcl_error("Operation failed: %s" % str(e)) From 89410b074011a0daab7b5125096eba9a04d0ae00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Mon, 12 Aug 2019 21:51:50 +0200 Subject: [PATCH 2/8] New TCL Command OpenFolder added --- tclCommands/TclCommandOpenFolder.py | 48 +++++++++++++++++++++++++++++ tclCommands/__init__.py | 1 + 2 files changed, 49 insertions(+) create mode 100644 tclCommands/TclCommandOpenFolder.py diff --git a/tclCommands/TclCommandOpenFolder.py b/tclCommands/TclCommandOpenFolder.py new file mode 100644 index 00000000..0080822d --- /dev/null +++ b/tclCommands/TclCommandOpenFolder.py @@ -0,0 +1,48 @@ +from tclCommands.TclCommand import * +from PyQt5.QtWidgets import QFileDialog + + +class TclCommandOpenFolder(TclCommand): + """ + Tcl shell command to get open a folder browser dialog and return the result + + example: + open_folder + """ + + # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon) + aliases = ['open_folder'] + + # Dictionary of types from Tcl command, needs to be ordered + arg_names = collections.OrderedDict() + + # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value + option_types = collections.OrderedDict([ + ('dir', str) + ]) + + # array of mandatory options for current Tcl command: required = {'name','outname'} + required = [] + + # structured help for current command, args needs to be ordered + help = { + 'main': "Opens a dialog to browse for a folder", + 'args': collections.OrderedDict([ + ('dir', 'Initial directory to open') + ]), + 'examples': ['open_folder'] + } + + def execute(self, args, unnamed_args): + """ + execute current TCL shell command + + :param args: array of known named arguments and options + :param unnamed_args: array of other values which were passed into command + without -somename and we do not have them in known arg_names + :return: None or exception + """ + if "dir" in args: + return QFileDialog.getExistingDirectory(dir=args['dir']) + else: + return QFileDialog.getExistingDirectory() diff --git a/tclCommands/__init__.py b/tclCommands/__init__.py index b06014d7..005d49ab 100644 --- a/tclCommands/__init__.py +++ b/tclCommands/__init__.py @@ -37,6 +37,7 @@ import tclCommands.TclCommandOpenExcellon import tclCommands.TclCommandOpenGCode import tclCommands.TclCommandOpenGerber import tclCommands.TclCommandOpenProject +import tclCommands.TclCommandOpenFolder import tclCommands.TclCommandOptions import tclCommands.TclCommandPaint import tclCommands.TclCommandPanelize From 1a22ba7688d34394a634dd6e9108a9d8052a5a6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Sat, 7 Nov 2020 23:11:15 +0100 Subject: [PATCH 3/8] Bugfix when using NCC on multigeo --- appObjects/FlatCAMGeometry.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index c7c3ee52..4cca8075 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -2278,6 +2278,8 @@ class GeometryObject(FlatCAMObj, Geometry): dia_cnc_dict.update({ 'tooldia': tooldia_val }) + if "optimization_type" not in tools_dict[tooluid_key]['data']: + tools_dict[tooluid_key]['data']["optimization_type"] = self.app.defaults["geometry_optimization_type"] # find the tool_dia associated with the tooluid_key # search in the self.tools for the sel_tool_dia and when found see what tooluid has From 72945bcda8d2d93adfccbf4d2834acd4bf64fe7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Sat, 7 Nov 2020 23:12:29 +0100 Subject: [PATCH 4/8] Bugfix for NCC on gerber with gerber as reference --- appTools/ToolNCC.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appTools/ToolNCC.py b/appTools/ToolNCC.py index 7da7938e..5168ace7 100644 --- a/appTools/ToolNCC.py +++ b/appTools/ToolNCC.py @@ -2869,7 +2869,7 @@ class NonCopperClear(AppTool, Gerber): bounding_box = unary_union(geo_buff_list) elif ncc_sel_obj.kind == 'gerber': geo_n = unary_union(geo_n).convex_hull - bounding_box = unary_union(self.ncc_obj.solid_geometry).convex_hull.intersection(geo_n) + bounding_box = unary_union(ncc_sel_obj.solid_geometry).convex_hull.intersection(geo_n) bounding_box = bounding_box.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre) else: self.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported.")) @@ -3315,7 +3315,7 @@ class NonCopperClear(AppTool, Gerber): rest_geo = [] current_uid = 1 try: - tool = eval(self.app.defaults["tools_ncc_tools"])[0] + tool = eval(str(self.app.defaults["tools_ncc_tools"]))[0] except TypeError: tool = eval(self.app.defaults["tools_ncc_tools"]) From 36bfcdce6fc7965782eb4e1dda409ba628542dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Sat, 7 Nov 2020 23:13:20 +0100 Subject: [PATCH 5/8] Bugfix for tcl command NCC method --- tclCommands/TclCommandCopperClear.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index 94529d6f..6e0ad3c8 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -259,7 +259,7 @@ class TclCommandCopperClear(TclCommand): margin=margin, has_offset=has_offset, offset=offset, - method=method, + method=method_data, outname=outname, connect=connect, contour=contour, @@ -290,7 +290,7 @@ class TclCommandCopperClear(TclCommand): margin=margin, has_offset=has_offset, offset=offset, - method=method, + method=method_data, outname=outname, connect=connect, contour=contour, From 40f5bf9c120adecbed0cba1428e6626fd7f37bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Sat, 7 Nov 2020 23:14:00 +0100 Subject: [PATCH 6/8] Workaround: Could not use tcl command mill drills --- tclCommands/TclCommandMillDrills.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tclCommands/TclCommandMillDrills.py b/tclCommands/TclCommandMillDrills.py index 832738e6..ece29c45 100644 --- a/tclCommands/TclCommandMillDrills.py +++ b/tclCommands/TclCommandMillDrills.py @@ -93,8 +93,8 @@ class TclCommandMillDrills(TclCommandSignaled): else: args['use_thread'] = False - if not obj.drills: - self.raise_tcl_error("The Excellon object has no drills: %s" % name) + # if not obj.drills: + # self.raise_tcl_error("The Excellon object has no drills: %s" % name) try: if 'milled_dias' in args and args['milled_dias'] != 'all': From c4c1c87d535f4c9f0b310976f5e48ba384f543e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Sat, 7 Nov 2020 23:14:18 +0100 Subject: [PATCH 7/8] TCL command SplitGeometry added --- tclCommands/TclCommandSplitGeometry.py | 66 ++++++++++++++++++++++++++ tclCommands/__init__.py | 1 + 2 files changed, 67 insertions(+) create mode 100644 tclCommands/TclCommandSplitGeometry.py diff --git a/tclCommands/TclCommandSplitGeometry.py b/tclCommands/TclCommandSplitGeometry.py new file mode 100644 index 00000000..75a210ee --- /dev/null +++ b/tclCommands/TclCommandSplitGeometry.py @@ -0,0 +1,66 @@ +from tclCommands.TclCommand import TclCommand +from appObjects.FlatCAMGeometry import GeometryObject + +import collections +from copy import deepcopy + + +class TclCommandSplitGeometry(TclCommand): + """ + Tcl shell command to split a geometry by tools. + + example: + + """ + + # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon) + aliases = ['split_geometries', 'split_geometry'] + + description = '%s %s' % ( + "--", "Split one Geometry object into separate ones for each tool.") + + # Dictionary of types from Tcl command, needs to be ordered + arg_names = collections.OrderedDict([ + ('source_name', str), + ]) + + # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value + option_types = collections.OrderedDict([ + + ]) + + # array of mandatory options for current Tcl command: required = {'name','outname'} + required = ['source_name'] + + # structured help for current command, args needs to be ordered + help = { + 'main': "Runs a merge operation (join) on the Geometry objects.\n" + "The names of the Geometry objects to be merged will be entered after the outname,\n" + "separated by spaces. See the example below.\n" + "WARNING: if the name of an Geometry objects has spaces, enclose the name with quotes.", + 'args': collections.OrderedDict([ + ('source_name', 'Name of the new Geometry Object made by joining of other Geometry objects. Required'), + ]), + 'examples': ['join_geometry merged_new_geo geo_name_1 "geo name_2"'] + } + + def execute(self, args, unnamed_args): + """ + + :param args: + :param unnamed_args: + :return: + """ + + obj: GeometryObject = self.app.collection.get_by_name( + str(args['source_name'])) + if obj is None: + return "Object not found: %s" % args['source_name'] + + for uid in list(obj.tools.keys()): + def initialize(new_obj, app): + new_obj.multigeo = True + new_obj.tools[uid] = deepcopy(obj.tools[uid]) + name = "{0}_tool_{1}".format(args['source_name'], uid) + self.app.app_obj.new_object( + "geometry", name, initialize, plot=False) diff --git a/tclCommands/__init__.py b/tclCommands/__init__.py index bd494687..30971044 100644 --- a/tclCommands/__init__.py +++ b/tclCommands/__init__.py @@ -64,6 +64,7 @@ import tclCommands.TclCommandSetOrigin import tclCommands.TclCommandSetPath import tclCommands.TclCommandSetSys import tclCommands.TclCommandSkew +import tclCommands.TclCommandSplitGeometry import tclCommands.TclCommandSubtractPoly import tclCommands.TclCommandSubtractRectangle import tclCommands.TclCommandVersion From 97e179140c65d8000dfc4205e9bed300a4bede85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Niem=C3=B6ller?= Date: Sat, 7 Nov 2020 23:24:07 +0100 Subject: [PATCH 8/8] Description for TCL command SplitGeometry updated --- tclCommands/TclCommandSplitGeometry.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tclCommands/TclCommandSplitGeometry.py b/tclCommands/TclCommandSplitGeometry.py index 75a210ee..acbad273 100644 --- a/tclCommands/TclCommandSplitGeometry.py +++ b/tclCommands/TclCommandSplitGeometry.py @@ -34,14 +34,11 @@ class TclCommandSplitGeometry(TclCommand): # structured help for current command, args needs to be ordered help = { - 'main': "Runs a merge operation (join) on the Geometry objects.\n" - "The names of the Geometry objects to be merged will be entered after the outname,\n" - "separated by spaces. See the example below.\n" - "WARNING: if the name of an Geometry objects has spaces, enclose the name with quotes.", + 'main': "Creates a new geometry for every tool and fills it with the tools geometry data", 'args': collections.OrderedDict([ - ('source_name', 'Name of the new Geometry Object made by joining of other Geometry objects. Required'), + ('source_name', 'Name of the source Geometry Object. Required'), ]), - 'examples': ['join_geometry merged_new_geo geo_name_1 "geo name_2"'] + 'examples': ['split_geometry my_geometry'] } def execute(self, args, unnamed_args):