From cac92f75f2667655aeca23a3a2683f767bed14f7 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 12 Aug 2019 22:39:38 +0300 Subject: [PATCH] - improved the FlatCAMGerber.isolate() function to work for geometry in the form of list and also in case that the elements of the list are LinearRings (like when doing the Exterior Isolation) - in NCC Tool made sure that at each run the old objects are deleted --- FlatCAMObj.py | 37 +++++++++++++++++++++++++----- README.md | 2 ++ flatcamTools/ToolNonCopperClear.py | 8 +++++++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 80f77709..0cbb8ddf 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -879,21 +879,46 @@ class FlatCAMGerber(FlatCAMObj, Gerber): if invert: try: - if type(geom) is MultiPolygon: + try: pl = [] for p in geom: if p is not None: - pl.append(Polygon(p.exterior.coords[::-1], p.interiors)) + if isinstance(p, Polygon): + pl.append(Polygon(p.exterior.coords[::-1], p.interiors)) + elif isinstance(p, LinearRing): + pl.append(Polygon(p.coords[::-1])) geom = MultiPolygon(pl) - elif type(geom) is Polygon and geom is not None: - geom = Polygon(geom.exterior.coords[::-1], geom.interiors) - else: - log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> Unexpected Geometry") + except TypeError: + if isinstance(geom, Polygon) and geom is not None: + geom = Polygon(geom.exterior.coords[::-1], geom.interiors) + elif isinstance(geom, LinearRing) and geom is not None: + geom = Polygon(geom.coords[::-1]) + else: + log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> Unexpected Geometry %s" % + type(geom)) except Exception as e: log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e)) return 'fail' return geom + # if invert: + # try: + # if type(geom) is MultiPolygon: + # pl = [] + # for p in geom: + # if p is not None: + # pl.append(Polygon(p.exterior.coords[::-1], p.interiors)) + # geom = MultiPolygon(pl) + # elif type(geom) is Polygon and geom is not None: + # geom = Polygon(geom.exterior.coords[::-1], geom.interiors) + # else: + # log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> Unexpected Geometry %s" % + # type(geom)) + # except Exception as e: + # log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e)) + # return 'fail' + # return geom + # if float(self.options["isotooldia"]) < 0: # self.options["isotooldia"] = -self.options["isotooldia"] diff --git a/README.md b/README.md index e9ec3e33..79b3e5e7 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ CAD program, and create G-Code for Isolation routing. - done regression to solve the bug with multiple passes cutting from the copper features (I should remember not to make mods here) - if 'combine' is checked in Gerber isolation but there is only one pass, the resulting geometry will still be single geo - the 'passes' entry was changed to a IntSpinner so it will allow passes to be entered only in range (1, 999) - it will not allow entry of 0 which may create some issues +- improved the FlatCAMGerber.isolate() function to work for geometry in the form of list and also in case that the elements of the list are LinearRings (like when doing the Exterior Isolation) +- in NCC Tool made sure that at each run the old objects are deleted 11.08.2019 diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index 6b1bc12a..97aa9a3e 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/flatcamTools/ToolNonCopperClear.py @@ -332,6 +332,12 @@ class NonCopperClear(FlatCAMTool, Gerber): FlatCAMTool.run(self) self.set_tool_ui() + # reset those objects on a new run + self.ncc_obj = None + self.bound_obj = None + self.obj_name = '' + self.bound_obj_name = '' + self.build_ui() self.app.ui.notebook.setTabText(2, _("NCC Tool")) @@ -692,6 +698,8 @@ class NonCopperClear(FlatCAMTool, Gerber): self.build_ui() def on_ncc(self): + self.bound_obj = None + self.ncc_obj = None try: over = float(self.ncc_overlap_entry.get_value())