printrun-src/printrun/laser.py

changeset 37
926424f97c8e
parent 36
f4730ef55ca8
child 42
ea4c43494a19
equal deleted inserted replaced
36:f4730ef55ca8 37:926424f97c8e
412 412
413 travel_speed = self.settings.lc_travel_speed * 60 413 travel_speed = self.settings.lc_travel_speed * 60
414 engrave_speed = self.settings.lc_engrave_speed * 60 * self.settings.lc_svg_speed_factor 414 engrave_speed = self.settings.lc_engrave_speed * 60 * self.settings.lc_svg_speed_factor
415 415
416 errors = 0 416 errors = 0
417 elemidx = 0
417 418
418 for elem in root.iter(): 419 for elem in root.iter():
420 elemidx += 1
419 try: 421 try:
420 _, tag_suffix = elem.tag.split('}') 422 _, tag_suffix = elem.tag.split('}')
421 except ValueError: 423 except ValueError:
422 continue 424 continue
423 425
424 if tag_suffix in svg_shapes: 426 if tag_suffix in svg_shapes:
425 self.log("Parsing shape: %s" % tag_suffix) 427 try:
428 styles = elem.attrib['style'].split(';')
429 except KeyError:
430 styles = []
431 skip = False
432 for style in styles:
433 style = style.split(':')
434 if style[0] == 'stroke':
435 # ignore all stroke colors which are not #000000
436 if style[1] != "#000000":
437 self.log("Ignoring shape %s (%i) by stroke color" % (tag_suffix, elemidx))
438 skip = True
439 break
440 if skip:
441 continue
442
443 self.log("Parsing shape: %s (%i)" % (tag_suffix, elemidx))
426 shape_class = getattr(shapes_pkg, tag_suffix) 444 shape_class = getattr(shapes_pkg, tag_suffix)
427 shape_obj = shape_class(elem) 445 shape_obj = shape_class(elem)
428 d = shape_obj.d_path() 446 d = shape_obj.d_path()
429 mat = shape_obj.transformation_matrix() 447 mat = shape_obj.transformation_matrix()
430 448

mercurial