more fixes before trying to finish svg compiler

Sat, 04 Jun 2016 10:01:58 +0200

author
mbayer
date
Sat, 04 Jun 2016 10:01:58 +0200
changeset 21
8551b89bd05e
parent 20
03b34402d405
child 22
4c9bb8f93ae8

more fixes before trying to finish svg compiler

printrun-src/printrun/laser.py file | annotate | diff | comparison | revisions
printrun-src/printrun/svg2gcode/shapes.py file | annotate | diff | comparison | revisions
--- 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)
--- a/printrun-src/printrun/svg2gcode/shapes.py	Sat Jun 04 09:22:51 2016 +0200
+++ b/printrun-src/printrun/svg2gcode/shapes.py	Sat Jun 04 10:01:58 2016 +0200
@@ -134,16 +134,12 @@
     def __init__(self, xml_node, polytype):
         super(polycommon, self).__init__(xml_node)
         self.points = list()
-
         if not self.xml_node == None:
             polycommon_el = self.xml_node
             points = polycommon_el.get('points') if polycommon_el.get('points') else list()
             points =  points.split()
             for pa in points:
                 self.points.append(pa)
-            #if polycommon_el.get('fill'):
-            #    # Append first point to close shape
-            #    self.points.append(points[0])
         else:
             logging.error("polycommon: Unable to get the attributes for %s", self.xml_node)
 

mercurial