# HG changeset patch # User mdd # Date 1535020346 -7200 # Node ID 926424f97c8eac50a3b2128d50a6b2b14cae5502 # Parent f4730ef55ca8a9b14347e471707858c64a9e1fc8 SVG gcode generator: interpret color style if present diff -r f4730ef55ca8 -r 926424f97c8e printrun-src/printrun/laser.py --- a/printrun-src/printrun/laser.py Tue Sep 26 19:08:02 2017 +0200 +++ b/printrun-src/printrun/laser.py Thu Aug 23 12:32:26 2018 +0200 @@ -414,15 +414,33 @@ engrave_speed = self.settings.lc_engrave_speed * 60 * self.settings.lc_svg_speed_factor errors = 0 + elemidx = 0 for elem in root.iter(): + elemidx += 1 try: _, tag_suffix = elem.tag.split('}') except ValueError: continue if tag_suffix in svg_shapes: - self.log("Parsing shape: %s" % tag_suffix) + try: + styles = elem.attrib['style'].split(';') + except KeyError: + styles = [] + skip = False + for style in styles: + style = style.split(':') + if style[0] == 'stroke': + # ignore all stroke colors which are not #000000 + if style[1] != "#000000": + self.log("Ignoring shape %s (%i) by stroke color" % (tag_suffix, elemidx)) + skip = True + break + if skip: + continue + + self.log("Parsing shape: %s (%i)" % (tag_suffix, elemidx)) shape_class = getattr(shapes_pkg, tag_suffix) shape_obj = shape_class(elem) d = shape_obj.d_path()