From 1332050a6ac5a2ade338c2420bb649b3177a12d2 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 17 Nov 2020 02:00:25 +0200 Subject: [PATCH] - the Follow Geometry outputted by the Follow Tools is now of type multigeo which means that it can be fused with other multigeo object without much pain --- CHANGELOG.md | 4 ++++ appObjects/FlatCAMGerber.py | 45 ++++++++++++++++++++++++++++++++++--- appTools/ToolFollow.py | 2 ++ app_Main.py | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7730b3f7..a97ddfc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +17.11.2020 + +- the Follow Geometry outputted by the Follow Tools is now of type multigeo which means that it can be fused with other multigeo object without much pain + 16.11.2020 - modified the behavior of the Tool Tab in the Notebook widget. Now the app start with the Tool Tab off. If an App Tool is launched then the Tool Tab is added and populated. If the same App Tool is launched again and the focus is in its Tool Tab then the Tool Tab is removed but if the focus is elsewhere then the focus is set again on the Tool Tab. diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py index 18bf8247..b6834710 100644 --- a/appObjects/FlatCAMGerber.py +++ b/appObjects/FlatCAMGerber.py @@ -773,10 +773,49 @@ class GerberObject(FlatCAMObj, Gerber): else: follow_name = outname - def follow_init(follow_obj, app_obj): + def follow_init(new_obj, app_obj): + if type(app_obj.defaults["geometry_cnctooldia"]) == float: + tools_list = [app_obj.defaults["geometry_cnctooldia"]] + else: + try: + temp_tools = app_obj.defaults["geometry_cnctooldia"].split(",") + tools_list = [ + float(eval(dia)) for dia in temp_tools if dia != '' + ] + except Exception as e: + log.error("GerberObject.follow_geo -> At least one tool diameter needed. -> %s" % str(e)) + return 'fail' + # Propagate options - follow_obj.options["cnctooldia"] = str(self.app.defaults["tools_iso_tooldia"]) - follow_obj.solid_geometry = self.follow_geometry + new_obj.multigeo = True + # new_obj.options["cnctooldia"] = str(self.app.defaults["tools_iso_tooldia"]) + new_obj.solid_geometry = deepcopy(self.follow_geometry) + + new_obj.options["cnctooldia"] = app_obj.defaults["geometry_cnctooldia"] + + # store here the default data for Geometry Data + default_data = {} + for opt_key, opt_val in app_obj.options.items(): + if opt_key.find('geometry' + "_") == 0: + oname = opt_key[len('geometry') + 1:] + default_data[oname] = self.app.options[opt_key] + if opt_key.find('tools_mill' + "_") == 0: + oname = opt_key[len('tools_mill') + 1:] + default_data[oname] = self.app.options[opt_key] + + new_obj.tools = { + 1: { + 'tooldia': app_obj.dec_format(float(tools_list[0]), self.decimals), + 'offset': 'Path', + 'offset_value': 0.0, + 'type': 'Rough', + 'tool_type': 'C1', + 'data': deepcopy(default_data), + 'solid_geometry': new_obj.solid_geometry + } + } + + new_obj.tools[1]['data']['name'] = follow_name try: self.app.app_obj.new_object("geometry", follow_name, follow_init) diff --git a/appTools/ToolFollow.py b/appTools/ToolFollow.py index 0909643d..68244ceb 100644 --- a/appTools/ToolFollow.py +++ b/appTools/ToolFollow.py @@ -271,6 +271,8 @@ class ToolFollow(AppTool, Gerber): """ def follow_init(new_obj, app_obj): + new_obj.multigeo = True + if type(app_obj.defaults["geometry_cnctooldia"]) == float: tools_list = [app_obj.defaults["geometry_cnctooldia"]] else: diff --git a/app_Main.py b/app_Main.py index dc3a4b10..3e954580 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2586,7 +2586,7 @@ class App(QtCore.QObject): edited_obj.options['ymin'] = ymin edited_obj.options['xmax'] = xmax edited_obj.options['ymax'] = ymax - except AttributeError as e: + except (AttributeError, ValueError) as e: self.inform.emit('[WARNING] %s' % _("Object empty after edit.")) self.log.debug("App.editor2object() --> Geometry --> %s" % str(e))