Further work on multi-pass cuts.

This commit is contained in:
Juan Pablo Caram
2015-10-11 20:58:21 -04:00
parent d687fb5287
commit ee684e8101

View File

@@ -2797,6 +2797,7 @@ class CNCjob(Geometry):
depth = 0 depth = 0
while depth > self.z_cut: while depth > self.z_cut:
depth -= depthpercut depth -= depthpercut
# TODO: Working...
# G-code # G-code
# Note: self.linear2gcode() and self.point2gcode() will # Note: self.linear2gcode() and self.point2gcode() will
# lower and raise the tool every time. # lower and raise the tool every time.
@@ -3051,7 +3052,9 @@ class CNCjob(Geometry):
# TODO: This takes forever. Too much data? # TODO: This takes forever. Too much data?
self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed]) self.solid_geometry = cascaded_union([geo['geom'] for geo in self.gcode_parsed])
def linear2gcode(self, linear, tolerance=0, down=True, up=True): def linear2gcode(self, linear, tolerance=0, down=True, up=True,
zcut=None, ztravel=None, downrate=None,
feedrate=None, cont=False):
""" """
Generates G-code to cut along the linear feature. Generates G-code to cut along the linear feature.
@@ -3060,33 +3063,55 @@ class CNCjob(Geometry):
:param tolerance: All points in the simplified object will be within the :param tolerance: All points in the simplified object will be within the
tolerance distance of the original geometry. tolerance distance of the original geometry.
:type tolerance: float :type tolerance: float
:return: G-code to cut alon the linear feature. :return: G-code to cut along the linear feature.
:rtype: str :rtype: str
""" """
if zcut is None:
zcut = self.z_cut
if ztravel is None:
ztravel = self.z_move
if downrate is None:
downrate = self.zdownrate
if feedrate is None:
feedrate = self.feedrate
t = "G0%d " + CNCjob.defaults["coordinate_format"] + "\n"
# Simplify paths?
if tolerance > 0: if tolerance > 0:
target_linear = linear.simplify(tolerance) target_linear = linear.simplify(tolerance)
else: else:
target_linear = linear target_linear = linear
gcode = "" gcode = ""
#t = "G0%d X%.4fY%.4f\n"
t = "G0%d " + CNCjob.defaults["coordinate_format"] + "\n"
path = list(target_linear.coords) path = list(target_linear.coords)
gcode += t % (0, path[0][0], path[0][1]) # Move to first point
if self.zdownrate is not None: # Move fast to 1st point
gcode += "F%.2f\n" % self.zdownrate if not cont:
gcode += "G01 Z%.4f\n" % self.z_cut # Start cutting gcode += t % (0, path[0][0], path[0][1]) # Move to first point
gcode += "F%.2f\n" % self.feedrate
else:
gcode += "G01 Z%.4f\n" % self.z_cut # Start cutting
# Move down to cutting depth
if down:
# Different feedrate for vertical cut?
if self.zdownrate is not None:
gcode += "F%.2f\n" % downrate
gcode += "G01 Z%.4f\n" % zcut # Start cutting
gcode += "F%.2f\n" % feedrate # Restore feedrate
else:
gcode += "G01 Z%.4f\n" % zcut # Start cutting
# Cutting...
for pt in path[1:]: for pt in path[1:]:
gcode += t % (1, pt[0], pt[1]) # Linear motion to point gcode += t % (1, pt[0], pt[1]) # Linear motion to point
# Up to travelling height.
if up: if up:
gcode += "G00 Z%.4f\n" % self.z_move # Stop cutting gcode += "G00 Z%.4f\n" % ztravel # Stop cutting
return gcode return gcode