- Drilling cut in Cutout Tool now works for geometry with multiple segments

This commit is contained in:
Marius Stanciu
2020-11-11 01:39:56 +02:00
committed by Marius
parent 953be31f6e
commit dc2143f4c9
2 changed files with 38 additions and 8 deletions

View File

@@ -20,6 +20,7 @@ CHANGELOG for FlatCAM beta
- fixed Paint Tcl command; fixes issue #437 - fixed Paint Tcl command; fixes issue #437
- updated the setup_ubuntu.sh script - updated the setup_ubuntu.sh script
- finished adding new feature in Cutout Tool: cut a geometry by drilling along its path - finished adding new feature in Cutout Tool: cut a geometry by drilling along its path
- Drilling cut in Cutout Tool now works for geometry with multiple segments
9.11.2020 9.11.2020

View File

@@ -1347,17 +1347,46 @@ class CutOut(AppTool):
_("There is no object selected for Cutout.\nSelect one and try again.")) _("There is no object selected for Cutout.\nSelect one and try again."))
return return
cut_geo = unary_union(obj.solid_geometry).buffer(margin, join_style=2).exterior cut_geo_solid = unary_union(obj.solid_geometry)
geo_length = cut_geo.length
drill_list = [] drill_list = []
dist = 0 try:
while dist <= geo_length: for geo in cut_geo_solid:
drill_list.append(cut_geo.interpolate(dist)) if isinstance(geo, LineString):
dist += pitch cut_geo = geo.parallel_offset(margin, side='left')
elif isinstance(geo, Polygon):
cut_geo = geo.buffer(margin).exterior
else:
self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Failed."), _("Could not add drills.")))
return
if dist < geo_length: geo_length = cut_geo.length
drill_list.append(Point(list(cut_geo.coords)[-1]))
dist = 0
while dist <= geo_length:
drill_list.append(cut_geo.interpolate(dist))
dist += pitch
if dist < geo_length:
drill_list.append(Point(list(cut_geo.coords)[-1]))
except TypeError:
if isinstance(cut_geo_solid, LineString):
cut_geo = cut_geo_solid.parallel_offset(margin, side='left')
elif isinstance(cut_geo_solid, Polygon):
cut_geo = cut_geo_solid.buffer(margin).exterior
else:
self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Failed."), _("Could not add drills.")))
return
geo_length = cut_geo.length
dist = 0
while dist <= geo_length:
drill_list.append(cut_geo.interpolate(dist))
dist += pitch
if dist < geo_length:
drill_list.append(Point(list(cut_geo.coords)[-1]))
if not drill_list: if not drill_list:
self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Failed."), _("Could not add drills."))) self.app.inform.emit('[WARNING_NOTCL] %s %s' % (_("Failed."), _("Could not add drills.")))