--- a/printrun-src/printrun/laser.py Sat Jun 04 09:22:51 2016 +0200 +++ b/printrun-src/printrun/laser.py Sat Jun 04 10:01:58 2016 +0200 @@ -53,11 +53,12 @@ """ % (TRAVEL_SPEED, ENGRAVE_SPEED) -GCODE_FOOT = """M400 ; Wait for all moves to finish +GCODE_FOOT = """G0 X0 Y0 F%.4f +M400 ; Wait for all moves to finish M571 S0 E0 M42 P28 S0 ; Force laser off! M501 ; undo all settings made -""" +""" % (TRAVEL_SPEED) from PIL import Image import sys @@ -77,7 +78,8 @@ def __init__(self, pronterwindow = None): if pronterwindow: self.pronterwindow = pronterwindow - self.log = pronterwindow.log + #self.log = pronterwindow.log + self.log = self.log_print self.pronterwindow.clear_log(None) else: self.pronterwindow = None @@ -89,6 +91,9 @@ TRAVEL_SPEED / 60, ENGRAVE_SPEED / 60) ) self.log("") + def log_print(self, msg): + print(msg) + def pixel2bit(self, pixel, threshold=128): """Convert the pixel value to a bit.""" @@ -333,7 +338,9 @@ fo.write("G0 X%0.2f Y%0.2f F%.4f ; Move to start of shape\n" % (xs, ys, TRAVEL_SPEED)) start = False xo = xs - yo = ys + yo = ys + object_xs = xs + object_ys = ys else: e_distance = math.hypot(xs - xo, ys - yo) xo = xs @@ -342,6 +349,13 @@ fo.write("G1 X%0.2f Y%0.2f E%.4f F%.4f\n" % (xs, ys, E * E_FACTOR, ENGRAVE_SPEED)) else: self.log("Position outside print dimension: %d, %d" % (xs, ys)) + if shape_obj.xml_node.get('fill'): + # Close the polygon + e_distance = math.hypot(object_xs - xo, object_ys - yo) + E = E + (e_distance) + fo.write("G1 X%0.2f Y%0.2f E%.4f F%.4f ; Close the object polygon\n" % (object_xs, object_ys, E * E_FACTOR, ENGRAVE_SPEED)) + print "connecting polycommon path end to start" + fo.write(shape_postamble) fo.write(GCODE_FOOT)