svg2gcode/svg2gcode.py

changeset 13
e2fd4d7b3cb6
parent 12
a90b8113be25
--- a/svg2gcode/svg2gcode.py	Sun Nov 08 05:03:45 2015 +0100
+++ b/svg2gcode/svg2gcode.py	Sun Nov 08 05:21:58 2015 +0100
@@ -79,7 +79,9 @@
     style = parser.parse_style_attr(stylestr)
     data = {}
     for obj in style[0]:
-        data[obj.name] = obj.value[0].value
+        val = obj.value[0]
+        if hasattr(val, 'value'):
+            data[obj.name] = val.value
     return data
 
 class Image(object):
@@ -118,9 +120,9 @@
         b1x, b1y = self.bb1.coord()
         b2x, b2y = self.bb2.coord()
         page = box(b1x, b1y, b2x, b2y)
-        # TODO: Infill spacing needs to be calculated with proper scaling and gcode MM dimensions
-        # TODO: Make infill angle 0, 45 or 90 degrees configurable to options parser (0° = X, 90° = Y, 45° = X and Y but half the speed/accel needed!)
-        self.infill = hatchbox(page, 0, 2)
+        # TODO: Infill spacing needs to be calculated with proper scaling and gcode MM dimensions, when set to 0 (auto)
+        # Make infill angle 0, 45 or 90 degrees configurable to options parser (0° = X, 90° = Y, 45° = X and Y but half the speed/accel needed!)
+        self.infill = hatchbox(page, self.options.infill_angle, self.options.infill_spacing)
 
     def normalize(self, coord):
         """
@@ -299,6 +301,12 @@
     parser.add_option("-o", "--outline", action="store_true",
                       dest="outline", default=False,
                       help="no infill, only outlines")
+    parser.add_option("", "--infill-angle",
+                      dest="infill_angle", type="int", default=45,
+                      help="infill angle: 0 = X, 90 = Y (default 45)")
+    parser.add_option("", "--infill-spacing",
+                      dest="infill_spacing", type="float", default=1.5,
+                      help="infill spacing in SVG units (default 1.5)")
     return parser.parse_args()
 
 if __name__ == "__main__":

mercurial