# HG changeset patch # User mbayer # Date 1446955425 -3600 # Node ID a90b8113be250454da207af02583b239287c6981 # Parent e7feabe182348590c9f2e1abb55538a8ce67697b bugfixes diff -r e7feabe18234 -r a90b8113be25 svg2gcode/svg/svg.py --- a/svg2gcode/svg/svg.py Sun Nov 08 04:18:58 2015 +0100 +++ b/svg2gcode/svg/svg.py Sun Nov 08 05:03:45 2015 +0100 @@ -248,6 +248,10 @@ def __init__(self, elt=None): Transformable.__init__(self, elt) + if elt is not None: + self.style = elt.get('style') + else: + self.style = '' def append(self, element): for elt in element: @@ -261,6 +265,10 @@ item.matrix = self.matrix * item.matrix item.viewport = self.viewport + # inherit style from group + if item.style == '': + item.style = self.style + self.items.append(item) # Recursively append if elt is a (group) if elt.tag == svg_ns + 'g': diff -r e7feabe18234 -r a90b8113be25 svg2gcode/svg2gcode.py --- 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