- modified the bounding box utility feature in the Gerber Object UI to work with buffer value of 0.0 and rounded corners

This commit is contained in:
Marius Stanciu
2022-01-26 12:23:12 +02:00
committed by Marius
parent 5a912c6885
commit 5d3fce12d5
3 changed files with 15 additions and 3 deletions

View File

@@ -461,7 +461,7 @@ class GerberObject(FlatCAMObj, Gerber):
non_copper = bounding_box.difference(self.solid_geometry)
non_copper = flatten_shapely_geometry(non_copper)
if non_copper is None or non_copper.is_empty:
if non_copper is None or (not isinstance(non_copper, list) and non_copper.is_empty):
app_obj.inform.emit("[ERROR_NOTCL] %s" % _("Operation could not be done."))
return "fail"
geo_obj.solid_geometry = non_copper
@@ -483,7 +483,15 @@ class GerberObject(FlatCAMObj, Gerber):
self.solid_geometry = unary_union(self.solid_geometry)
# Bounding box with rounded corners
bounding_box = self.solid_geometry.envelope.buffer(float(self.options["bboxmargin"]))
if isinstance(self.solid_geometry, Polygon):
bounding_box = self.solid_geometry.buffer(float(self.options["bboxmargin"])).exterior
elif isinstance(self.solid_geometry, MultiPolygon):
try:
bounding_box = self.solid_geometry.buffer(float(self.options["bboxmargin"])).exterior
except Exception:
bounding_box = self.solid_geometry.envelope.buffer(float(self.options["bboxmargin"]))
else:
bounding_box = self.solid_geometry.envelope.buffer(float(self.options["bboxmargin"]))
if not self.options["bboxrounded"]: # Remove rounded corners
bounding_box = bounding_box.envelope