From 1467c5e0bcd0dc264c55cfedcea739be79f94558 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 29 Jan 2022 22:21:32 +0200 Subject: [PATCH] - fixed some issues in the `ncc` Tcl command --- CHANGELOG.md | 1 + camlib.py | 4 +-- tclCommands/TclCommandCopperClear.py | 42 +++++++++++++++------------- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a883dd1..26690842 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta - cleaned up Marlin preprocessors - in the `panelize`, `cutout` and `geocutout` Tcl commands updated the error strings and made sure that if an error occur then a potential script execution in chain is aborted - updated the `new` Tcl command: now it has an argument `-keep_scripts` that when True, will keep the loaded scripts in the new project +- fixed some issues in the `ncc` Tcl command 28.01.2022 diff --git a/camlib.py b/camlib.py index 4d43e5b9..10cb39b9 100644 --- a/camlib.py +++ b/camlib.py @@ -1475,7 +1475,7 @@ class Geometry(object): # current can be a MultiPolygon try: - for p in current: + for p in current.geoms: geoms.insert(p.exterior) for i in p.interiors: geoms.insert(i) @@ -1483,7 +1483,7 @@ class Geometry(object): self.plot_temp_shapes(p) # Not a Multipolygon. Must be a Polygon - except TypeError: + except (TypeError, AttributeError): geoms.insert(current.exterior) if prog_plot: self.plot_temp_shapes(current.exterior) diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index 0502ed8c..e5addd94 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -189,14 +189,14 @@ class TclCommandCopperClear(TclCommand): select = 2 # 'REFERENCE Object' # store here the default data for Geometry Data - default_data = {} + default_data = self.app.options.copy() default_data.update({ "name": outname, "plot": False, "tools_mill_cutz": self.app.defaults["tools_mill_cutz"], "tools_mill_vtipdia": float(self.app.defaults["tools_mill_vtipdia"]), "tools_mill_vtipangle": float(self.app.defaults["tools_mill_vtipangle"]), - "tools_mill_travelz": self.app.defaults["tools_mill__travelz"], + "tools_mill_travelz": self.app.defaults["tools_mill_travelz"], "tools_mill_feedrate": self.app.defaults["tools_mill_feedrate"], "tools_mill_feedrate_z": self.app.defaults["tools_mill_feedrate_z"], "tools_mill_feedrate_rapid": self.app.defaults["tools_mill_feedrate_rapid"], @@ -215,24 +215,24 @@ class TclCommandCopperClear(TclCommand): "tools_mill_toolchangexy": self.app.defaults["tools_mill_toolchangexy"], "tools_mill_startz": self.app.defaults["tools_mill_startz"], - "area_exclusion": self.app.defaults["geometry_area_exclusion"], - "area_shape": self.app.defaults["geometry_area_shape"], - "area_strategy": self.app.defaults["geometry_area_strategy"], - "area_overz": float(self.app.defaults["geometry_area_overz"]), + "area_exclusion": self.app.defaults["tools_mill_area_exclusion"], + "area_shape": self.app.defaults["tools_mill_area_shape"], + "area_strategy": self.app.defaults["tools_mill_area_strategy"], + "area_overz": float(self.app.defaults["tools_mill_area_overz"]), - "tooldia": tooldia, - "tools_ncc_operation": self.app.defaults["tools_ncc_operation"], + "tooldia": tooldia, + "tools_ncc_operation": self.app.defaults["tools_ncc_operation"], - "tools_ncc_margin": margin, - "tools_ncc_method": method_data, - "tools_ncc_ref": select, - "tools_ncc_connect": connect, - "tools_ncc_contour": contour, - "tools_ncc_overlap": overlap, + "tools_ncc_margin": margin, + "tools_ncc_method": method_data, + "tools_ncc_ref": select, + "tools_ncc_connect": connect, + "tools_ncc_contour": contour, + "tools_ncc_overlap": overlap, - "tools_ncc_offset_choice": self.app.defaults["tools_ncc_offset_choice"], - "tools_ncc_offset_value": self.app.defaults["tools_ncc_offset_value"], - "tools_ncc_milling_type": self.app.defaults["tools_ncc_milling_type"] + "tools_ncc_offset_choice": self.app.defaults["tools_ncc_offset_choice"], + "tools_ncc_offset_value": self.app.defaults["tools_ncc_offset_value"], + "tools_ncc_milling_type": self.app.defaults["tools_ncc_milling_type"] }) ncc_tools = {} @@ -276,9 +276,10 @@ class TclCommandCopperClear(TclCommand): try: box_obj = self.app.collection.get_by_name(str(box_name)) except Exception as e: - log.error("TclCommandCopperClear.execute() --> %s" % str(e)) + self.app.log.error("TclCommandCopperClear.execute() --> %s" % str(e)) + self.app.log.error("Could not retrieve object: %s" % name) self.raise_tcl_error("%s: %s" % (_("Could not retrieve object"), name)) - return "Could not retrieve object: %s" % name + return "fail" self.app.ncclear_tool.clear_copper_tcl(ncc_obj=obj, sel_obj=box_obj, @@ -300,5 +301,6 @@ class TclCommandCopperClear(TclCommand): return # if the program reached this then it's an error because neither -all or -box was used. + self.app.log.error("Expected either -box or -all. Copper clearing failed.") self.raise_tcl_error('%s' % _("Expected either -box or -all.")) - return "Expected either -box or -all. Copper clearing failed." + return "fail"