Thu, 23 Aug 2018 12:32:26 +0200
SVG gcode generator: interpret color style if present
printrun-src/printrun/laser.py | file | annotate | diff | comparison | revisions |
--- 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()