johannesnoordanus / svg2gcode

MIT License
5 stars 2 forks source link

Not able to convert images from inkscape (anymore?) #13

Closed fdev31 closed 1 day ago

fdev31 commented 2 weeks ago

After a long time without using the engraver, I wanted to use grblhud & svg2image again but got issues from the start:

$ svg2gcode --splitfile --pixelsize 0.04 --no-constantburn --pathcut --cuttingpower 10000 --xmaxtravel 400 /tmp/x.svg /tmp/laser

[WARNING] Cut is not within machine bounds.
[INFO] Generated /tmp/laser
list index out of range

The output file doesn't contain any real info but have warnings such as "; no stroke color set: ignore path 'path1'"

I can reproduce it just with a circle converted to a path.

x

fdev31 commented 2 weeks ago

After some bisection, it broke after this commit:

1e966276174d097870e0b82482af5a5dc6e49446 is the first bad commit
commit 1e966276174d097870e0b82482af5a5dc6e49446
Author: Johannes Noordanus <johannes_noordanus@icloud.com>
Date:   Sat Aug 3 23:26:56 2024 +0200

    Fix of several alpha channel issues, fix of color inversion, fix of fill (fonts)
fdev31 commented 2 weeks ago

Looks like the following change in _compiler is the culprit:

                    # line stroke isn't set: cut path
                    self.body.extend([f"\n; no stroke color: cut path '{name_id}'"])
                    render_pathwidth(line_chain, [0], None, None, boundingbox)

Has changed into:

                    # line stroke isn't set: ignore path
                    self.body.extend([f"\n; no stroke color set: ignore path '{name_id}'"])
                    #render_pathwidth(line_chain, [0], None, None, boundingbox)

seems that the issue is that the stroke detected in the first place, but on older versions it would still work thanks to this code.

fdev31 commented 2 weeks ago

Additional note, the new versions seem to have some invalid syntax:

/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:556: SyntaxWarning: invalid escape sequence '\d'
  fill_opacity = re.search("fill-opacity:(\d*\.)?\d+", style_str)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:559: SyntaxWarning: invalid escape sequence '\d'
  "(\d*\.)?\d+", fill_opacity.group(0)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:570: SyntaxWarning: invalid escape sequence '\d'
  stroke_width = re.search("stroke-width:(\d*\.)?\d+", style_str)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:573: SyntaxWarning: invalid escape sequence '\d'
  "(\d*\.)?\d+", stroke_width.group(0)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:577: SyntaxWarning: invalid escape sequence '\d'
  stroke_opacity = re.search("stroke-opacity:(\d*\.)?\d+", style_str)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:580: SyntaxWarning: invalid escape sequence '\d'
  "(\d*\.)?\d+", stroke_opacity.group(0)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:601: SyntaxWarning: invalid escape sequence '\d'
  fill_opacity = re.search("fill-opacity:(\d*\.)?\d+", curve.path_attrib)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:604: SyntaxWarning: invalid escape sequence '\d'
  "(\d*\.)?\d+", fill_opacity.group(0)
/tmp/code/svg2gcode/svg2gcode/svg_to_gcode/compiler/_compiler.py:664: SyntaxWarning: invalid escape sequence '\['
  colors = re.sub("(,|\[|\]|'| )", "", colors.replace(",", "|"))

prefixing the strings with r seems to fix the warnings.

fdev31 commented 2 weeks ago

Ok, I figured there was something wrong with the input file. Closing the ticket. Thank you for the great work!

fdev31 commented 1 week ago

Ok, I'm having this issue again: no stroke color set: ignore path 'path7'

not sure what triggers it yet, so I'll dump all my setup:

constantburn = true
pixelsize = 0.06
xmaxtravel= 400
ymaxtravel= 400
imagespeed = 6000
cuttingspeed = 6000
imagepower = 300
cuttingpower = 1000
overscan = 5

source image:

sara

fdev31 commented 1 day ago

Now the cutting is handled in a different way, my bad.