- 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
This commit is contained in:
Marius Stanciu 2019-08-12 22:39:38 +03:00
parent fd104eee55
commit cac92f75f2
3 changed files with 41 additions and 6 deletions

View File

@ -879,21 +879,46 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
if invert: if invert:
try: try:
if type(geom) is MultiPolygon: try:
pl = [] pl = []
for p in geom: for p in geom:
if p is not None: 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) geom = MultiPolygon(pl)
elif type(geom) is Polygon and geom is not None: except TypeError:
geom = Polygon(geom.exterior.coords[::-1], geom.interiors) if isinstance(geom, Polygon) and geom is not None:
else: geom = Polygon(geom.exterior.coords[::-1], geom.interiors)
log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> Unexpected Geometry") 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: except Exception as e:
log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e)) log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e))
return 'fail' return 'fail'
return geom 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: # if float(self.options["isotooldia"]) < 0:
# self.options["isotooldia"] = -self.options["isotooldia"] # self.options["isotooldia"] = -self.options["isotooldia"]

View File

@ -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) - 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 - 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 - 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 11.08.2019

View File

@ -332,6 +332,12 @@ class NonCopperClear(FlatCAMTool, Gerber):
FlatCAMTool.run(self) FlatCAMTool.run(self)
self.set_tool_ui() 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.build_ui()
self.app.ui.notebook.setTabText(2, _("NCC Tool")) self.app.ui.notebook.setTabText(2, _("NCC Tool"))
@ -692,6 +698,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.build_ui() self.build_ui()
def on_ncc(self): def on_ncc(self):
self.bound_obj = None
self.ncc_obj = None
try: try:
over = float(self.ncc_overlap_entry.get_value()) over = float(self.ncc_overlap_entry.get_value())