- modified the bounding box utility feature in the Gerber Object UI to work with negative margin values

This commit is contained in:
Marius Stanciu
2022-01-26 13:49:48 +02:00
committed by Marius
parent b69738d852
commit 805cf75e85
2 changed files with 25 additions and 9 deletions

View File

@@ -11,10 +11,11 @@ CHANGELOG for FlatCAM beta
- fixed the Cutout plugin not working with Geometry objects that are made out of a LineString or LinearRing geometric elements - fixed the Cutout plugin not working with Geometry objects that are made out of a LineString or LinearRing geometric elements
- fixed the Cutout plugin for the rectangular cutout: the name of the resulting object is now correct if there is no extension in the source file - fixed the Cutout plugin for the rectangular cutout: the name of the resulting object is now correct if there is no extension in the source file
- modified the bounding box utility feature in the Gerber Object UI to work with buffer value of 0.0 and rounded corners - modified the bounding box utility feature in the Gerber Object UI to work with margin value of 0.0 and rounded corners
- in Cutout plugin added the ability to create Manual Geometries with negative tool diameters - in Cutout plugin added the ability to create Manual Geometries with negative tool diameters
- fix the Transform plugin, buffer functionality for Geometry objects such that the buffer with negative values will work by crating a buffer toward the interior of that geometry - fix the Transform plugin, buffer functionality for Geometry objects such that the buffer with negative values will work by crating a buffer toward the interior of that geometry
- minor changes - minor changes
- modified the bounding box utility feature in the Gerber Object UI to work with negative margin values
25.01.2022 25.01.2022

View File

@@ -482,16 +482,31 @@ class GerberObject(FlatCAMObj, Gerber):
except Exception: except Exception:
self.solid_geometry = unary_union(self.solid_geometry) self.solid_geometry = unary_union(self.solid_geometry)
distance = float(self.options["bboxmargin"])
# Bounding box with rounded corners # Bounding box with rounded corners
if isinstance(self.solid_geometry, Polygon): if distance >= 0:
bounding_box = self.solid_geometry.buffer(float(self.options["bboxmargin"])).exterior if isinstance(self.solid_geometry, Polygon):
elif isinstance(self.solid_geometry, MultiPolygon): bounding_box = self.solid_geometry.buffer(distance).exterior
try: elif isinstance(self.solid_geometry, MultiPolygon):
bounding_box = self.solid_geometry.buffer(float(self.options["bboxmargin"])).exterior try:
except Exception: bounding_box = self.solid_geometry.buffer(distance).exterior
bounding_box = self.solid_geometry.envelope.buffer(float(self.options["bboxmargin"])) except Exception:
bounding_box = self.solid_geometry.envelope.buffer(distance)
else:
bounding_box = self.solid_geometry.envelope.buffer(distance)
else: else:
bounding_box = self.solid_geometry.envelope.buffer(float(self.options["bboxmargin"])) if isinstance(self.solid_geometry, Polygon):
bounding_box = self.solid_geometry.buffer(abs(distance*2)).interiors
elif isinstance(self.solid_geometry, MultiPolygon):
try:
bounding_box = self.solid_geometry.buffer(abs(distance*2)).interiors
except Exception:
bounding_box = self.solid_geometry.envelope.buffer(abs(distance*2)).interiors
else:
bounding_box = self.solid_geometry.envelope.buffer(abs(distance*2)).interiors
bounding_box = unary_union(bounding_box).buffer(-distance).exterior
if not self.options["bboxrounded"]: # Remove rounded corners if not self.options["bboxrounded"]: # Remove rounded corners
bounding_box = bounding_box.envelope bounding_box = bounding_box.envelope