From f00eb7b8599877c0481020edfbb460ad130e8ef6 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 1 Jul 2023 10:40:49 +0300 Subject: [PATCH] - NCC Plugin: fixed the determination of optimal tool - NCC Plugin: fixed a bug where when using the Rest Machining an error is issued due of trying to create a MultiPolygon having in the list another MultiPolygon; fixed by flattening the list --- CHANGELOG.md | 5 +++++ appPlugins/ToolNCC.py | 23 +++++++++++++++-------- camlib.py | 8 ++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 354d5bac..23d9e043 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM Evo beta ================================================= +1.07.2023 + +- NCC Plugin: fixed the determination of optimal tool +- NCC Plugin: fixed a bug where when using the Rest Machining an error is issued due of trying to create a MultiPolygon having in the list another MultiPolygon; fixed by flattening the list + 30.06.2023 - NCC Plugin: fixed the Isolation operation mode diff --git a/appPlugins/ToolNCC.py b/appPlugins/ToolNCC.py index fae8e75c..ea845e1d 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -967,16 +967,15 @@ class NonCopperClear(AppTool, Gerber): for ap in list(aperture_storage.keys()): if 'geometry' in aperture_storage[ap]: for geo_el in aperture_storage[ap]['geometry']: - if 'solid' in geo_el and geo_el['solid'] is not None and geo_el['solid'].is_valid: - total_geo.append(geo_el['solid']) + if 'solid' in geo_el and geo_el['solid'] is not None: + buff_geo = geo_el['solid'].buffer(0.0000001) + if buff_geo.is_valid: + total_geo.append(buff_geo) - total_geo = MultiPolygon(total_geo) - total_geo = total_geo.buffer(0) total_geo = flatten_shapely_geometry(total_geo) - if isinstance(total_geo, Polygon): - msg = ('[ERROR_NOTCL] %s' % _("The Gerber object has one Polygon as geometry.\n" - "There are no distances between geometry elements to be found.")) + if len(total_geo) in [0, 1]: + msg = ('[ERROR_NOTCL] %s' % _("Too few polygons in the Gerber object to determine distances.")) return msg, np.Inf min_dict = {} idx = 1 @@ -2759,9 +2758,17 @@ class NonCopperClear(AppTool, Gerber): if not cleared_geo: break buffered_cleared_geo = [line.buffer(tool / 2) for line in cleared_geo] + buffered_cleared_geo = flatten_shapely_geometry(buffered_cleared_geo) if not buffered_cleared_geo: break - new_area = MultiPolygon(buffered_cleared_geo) + try: + new_area = MultiPolygon(buffered_cleared_geo) + except Exception as err: + self.app.log.error("NonCopperClear.ncc_handler.gen_clear_area_rest() Buffering -> %s" % str(err)) + self.app.log.debug( + "NonCopperClear.ncc_handler.gen_clear_area_rest() Buffering -> %s" % str(traceback.format_exc()) + ) + return new_area = new_area.buffer(0.0000001) area = area.difference(new_area) diff --git a/camlib.py b/camlib.py index 6ec85f25..f68fd7e5 100644 --- a/camlib.py +++ b/camlib.py @@ -1507,7 +1507,7 @@ class Geometry(object): # Optimization: Reduce lifts if connect: # log.debug("Reducing tool lifts...") - self.app.inform.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) + self.app.inform_no_echo.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) self.app.proc_container.update_view_text(' %s' % _("Connecting..."), clear=True) geoms = Geometry.paint_connect(geoms, polygon, tooldia, int(steps_per_circle)) @@ -1619,7 +1619,7 @@ class Geometry(object): # Optimization: Reduce lifts if connect: # log.debug("Reducing tool lifts...") - self.app.inform.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) + self.app.inform_no_echo.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) self.app.proc_container.update_view_text(' %s' % _("Connecting..."), clear=True) geoms_conn = Geometry.paint_connect(geom_elems, polygon_to_clear, tooldia, steps_per_circle) if geoms_conn: @@ -1774,7 +1774,7 @@ class Geometry(object): # Optimization: Reduce lifts if connect: # log.debug("Reducing tool lifts...") - self.app.inform.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) + self.app.inform_no_echo.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) self.app.proc_container.update_view_text(' %s' % _("Connecting..."), clear=True) geoms_conn = Geometry.paint_connect(geoms, polygon, tooldia, steps_per_circle) if geoms_conn: @@ -1965,7 +1965,7 @@ class Geometry(object): # Optimization: Reduce lifts if connect: # log.debug("Reducing tool lifts...") - self.app.inform.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) + self.app.inform_no_echo.emit(_("Connect: reducing tool lifts. This may take a while, please wait...")) self.app.proc_container.update_view_text(' %s' % _("Connecting..."), clear=True) geoms_conn = Geometry.paint_connect(geoms, polygon, tooldia, steps_per_circle) if geoms_conn: