From 932f8143cd5566f9bf7e731c6375052d43ba1525 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 10 Dec 2019 05:33:32 +0200 Subject: [PATCH] - if extracut_length is zero then the extracut will cut up until the first point in path no matter what the distance is --- README.md | 1 + camlib.py | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 259e6554..5b496e4d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing. - small changes in the Geometry UI - now extracut option in the Geometry Object will recut as many points as many they are within the specified re-cut length +- if extracut_length is zero then the extracut will cut up until the first point in path no matter what the distance is 9.12.2019 diff --git a/camlib.py b/camlib.py index 090aeff5..63d4c52c 100644 --- a/camlib.py +++ b/camlib.py @@ -4633,22 +4633,27 @@ class CNCjob(Geometry): # between point 0 and point 1 is more than the distance we set for the extra cut then make an interpolation # along the path and find the point at the distance extracut_length - if abs(distance(path[1], path[0])) > extracut_length: - i_point = LineString([path[0], path[1]]).interpolate(extracut_length) - gcode += self.doformat(p.linear_code, x=i_point.x, y=i_point.y) + if extracut_length == 0.0: + gcode += self.doformat(p.linear_code, x=path[1][0], y=path[1][1]) + last_pt = path[1] else: - last_pt = path[0] - for pt in path[1:]: - extracut_distance = abs(distance(pt, last_pt)) - if extracut_distance <= extracut_length: - gcode += self.doformat(p.linear_code, x=pt[0], y=pt[1]) - last_pt = pt - else: - break + if abs(distance(path[1], path[0])) > extracut_length: + i_point = LineString([path[0], path[1]]).interpolate(extracut_length) + gcode += self.doformat(p.linear_code, x=i_point.x, y=i_point.y) + last_pt = (i_point.x, i_point.y) + else: + last_pt = path[0] + for pt in path[1:]: + extracut_distance = abs(distance(pt, last_pt)) + if extracut_distance <= extracut_length: + gcode += self.doformat(p.linear_code, x=pt[0], y=pt[1]) + last_pt = pt + else: + break # Up to travelling height. if up: - gcode += self.doformat(p.lift_code, x=pt[0], y=pt[1], z_move=z_move) # Stop cutting + gcode += self.doformat(p.lift_code, x=last_pt[0], y=last_pt[1], z_move=z_move) # Stop cutting return gcode