--- a/svg2gcode/svg2gcode.py Sun Nov 08 04:18:58 2015 +0100 +++ b/svg2gcode/svg2gcode.py Sun Nov 08 05:03:45 2015 +0100 @@ -73,7 +73,7 @@ Parse the given string containing CSS2.1 syntax Returns a dict with the keys/values """ - if stylestr.strip() == '': + if not stylestr or stylestr.strip() == '': return None parser = CSS21Parser() style = parser.parse_style_attr(stylestr) @@ -228,16 +228,26 @@ for pnt in l: segments.append(pnt.coord()) shape = Polygon(segments) - if shape.is_valid: - if not poly: - poly = shape - else: + #if shape.is_valid: + if not poly: + poly = shape + else: + try: if shape.within(poly): poly = poly.difference(shape) else: poly = poly.union(shape) + except Exception: + pass - lines = poly.intersection(image.infill) + if not poly: + continue + + try: + lines = poly.intersection(image.infill) + except Exception: + lines = None + if lines: #pprint (dir(lines)) # THE INFILL