- fixed issue in the isolation function, if the isolation can't be done there will be generated no Geometry object

This commit is contained in:
Marius Stanciu 2019-08-06 03:29:43 +03:00
parent 59b4defa0b
commit 5a141ad115
3 changed files with 22 additions and 10 deletions

View File

@ -876,17 +876,19 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
if invert:
try:
if type(geom) is MultiPolygon:
if type(geom) is MultiPolygon or type(geom) is list:
pl = []
for p in geom:
pl.append(Polygon(p.exterior.coords[::-1], p.interiors))
if p is not None:
pl.append(Polygon(p.exterior.coords[::-1], p.interiors))
geom = MultiPolygon(pl)
elif type(geom) is Polygon:
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 Exception as e:
log.debug("FlatCAMGerber.isolate().generate_envelope() Error --> %s" % str(e))
return 'fail'
return geom
if float(self.options["isotooldia"]) < 0:
@ -914,6 +916,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
geom = generate_envelope(iso_offset, 1, envelope_iso_type=self.iso_type, follow=follow)
else:
geom = generate_envelope(iso_offset, 0, envelope_iso_type=self.iso_type, follow=follow)
if geom == 'fail':
# app_obj.inform.emit(_("[ERROR_NOTCL] Isolation geometry could not be generated."))
return 'fail'
geo_obj.solid_geometry.append(geom)
# store here the default data for Geometry Data
@ -1006,11 +1011,14 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
# if milling type is climb then the move is counter-clockwise around features
if milling_type == 'cl':
# geo_obj.solid_geometry = generate_envelope(offset, i == 0)
geo_obj.solid_geometry = generate_envelope(offset, 1, envelope_iso_type=self.iso_type,
follow=follow)
geom = generate_envelope(offset, 1, envelope_iso_type=self.iso_type, follow=follow)
else:
geo_obj.solid_geometry = generate_envelope(offset, 0, envelope_iso_type=self.iso_type,
follow=follow)
geom = generate_envelope(offset, 0, envelope_iso_type=self.iso_type, follow=follow)
if geom == 'fail':
# app_obj.inform.emit(_("[ERROR_NOTCL] Isolation geometry could not be generated."))
return 'fail'
geo_obj.solid_geometry = geom
# detect if solid_geometry is empty and this require list flattening which is "heavy"
# or just looking in the lists (they are one level depth) and if any is not empty

View File

@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
- fixed bug that crashed the app after creating a new geometry, if a new object is loaded and the new geometry is deleted and then trying to select the just loaded new object
- made some GUI elements in Edit -> Preferences to have a minimum width as opposed to the previous fixed one
- fixed issue in the isolation function, if the isolation can't be done there will be generated no Geometry object
5.08.2019

View File

@ -544,6 +544,7 @@ class Geometry(object):
# the previously commented block is replaced with this block - regression - to solve the bug with multiple
# isolation passes cutting from the copper features
geo_iso = []
if offset == 0:
if follow:
geo_iso = self.follow_geometry
@ -557,14 +558,16 @@ class Geometry(object):
if type(self.solid_geometry) is list and len(self.solid_geometry) == 1:
geo_iso = self.solid_geometry[0].buffer(offset, int(int(self.geo_steps_per_circle) / 4))
else:
geo_iso = self.solid_geometry.buffer(offset, int(int(self.geo_steps_per_circle) / 4))
for el in self.solid_geometry:
geo_iso.append(el.buffer(offset, int(int(self.geo_steps_per_circle) / 4)))
else:
if type(self.solid_geometry) is list and len(self.solid_geometry) == 1:
geo_iso = self.solid_geometry.buffer[0](offset, int(int(self.geo_steps_per_circle) / 4),
join_style=corner)
else:
geo_iso = self.solid_geometry.buffer(offset, int(int(self.geo_steps_per_circle) / 4),
join_style=corner)
for el in self.solid_geometry:
geo_iso.append(el.buffer(offset, int(int(self.geo_steps_per_circle) / 4),
join_style=corner))
# end of replaced block
if follow: