Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep getting "IndexError: list index out of range" #2

Open
davidwachs opened this issue Sep 9, 2016 · 5 comments
Open

Keep getting "IndexError: list index out of range" #2

davidwachs opened this issue Sep 9, 2016 · 5 comments

Comments

@davidwachs
Copy link

Hey, AWESOME code, but I have an issue...

when it parses my svgs, I keep getting index out of range... any idea what I can do to fix this?

I get this even with simple SVGs:

<svg xmlns="http://www.w3.org/2000/svg" width="6120" height="7920" version="1.1">

 <path d="M 6.078125 -9.390625 C6.078125 -9.9375 6.265625 -11.046875 6.015625 -11.59375 L 5.96875 -11.59375C5.796875 -11.953125 5.296875 -12.09375 4.859375 -12.421875C4.640625 -12.59375 4.421875 -12.953125 4.140625 -12.953125C3.890625 -12.953125 3.3125 -12.703125 2.765625 -12.28125C1.578125 -11.375 0.109375 -9.75 0.109375 -8.671875C0.109375 -8.28125 0.4375 -7.953125 0.859375 -7.78125C2.484375 -7.0625 4.6875 -9.390625 6.078125 -9.390625ZM8.09375 -5.796875C6.4375 -5.65625 5.96875 -6.734375 6.046875 -8.921875C6.078125 -9.9375 6.265625 -11.625 6.265625 -12.34375L6.015625 -12.34375M8.09375 -5.796875" transform="translate(72, 100.8)"/>

</svg>

I've been struggling with this... any help you can lend would be amazing... thanks so much in advance.

@Harvie
Copy link

Harvie commented Jul 14, 2018

Does this still happen? update: yes it does:

Traceback (most recent call last):
  File "svg2gcode.py", line 60, in <module>
    generate_gcode()
  File "svg2gcode.py", line 51, in generate_gcode
    for x,y in p:
  File "/home/harvie/Temp/svg3gcode/shapes.py", line 184, in point_generator
    cspsubdiv.subdiv( sp, flatness)
  File "/home/harvie/Temp/svg3gcode/cspsubdiv.py", line 22, in subdiv
    p2 = sp[i][0]  
IndexError: list index out of range

It happens with your SVG, but not with mine SVGs... There's probably something that triggers it.

@Harvie
Copy link

Harvie commented Jul 14, 2018

I've used inkscape to break your svg into subpaths and one of the paths it created was empty:

  <path
     d="M 7.984375,7.15625"
     id="path2"
     inkscape:connector-curvature="0" />

probably svg2gcode should detect this and avoid processing such zero length shape?

@davidwachs
Copy link
Author

davidwachs commented Jul 14, 2018 via email

@davidwachs
Copy link
Author

davidwachs commented Jul 14, 2018 via email

@r3a2t10
Copy link

r3a2t10 commented Aug 18, 2019

I also met this problem when running svg

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="50px" height="50px" viewBox="0 0 50 50" version="1.1" fill="#000000">
  <g id="surface279232">
    <path style=" stroke:none;fill-rule:nonzero;fill:#000000;fill-opacity:1;" d="M 7.8125 7.8125 L 7.8125 42.1875 L 42.1875 42.1875 L 42.1875 7.8125 Z M 10.9375 10.9375 L 39.0625 10.9375 L 39.0625 39.0625 L 10.9375 39.0625 Z M 25 17.1875 C 21.546875 17.1875 18.75 19.984375 18.75 23.4375 L 18.75 26.5625 C 18.75 30.015625 21.546875 32.8125 25 32.8125 C 28.453125 32.8125 31.25 30.015625 31.25 26.5625 L 31.25 23.4375 C 31.25 19.984375 28.453125 17.1875 25 17.1875 Z M 25 20.3125 C 26.863281 20.3125 28.125 21.574219 28.125 23.4375 L 28.125 26.5625 C 28.125 28.425781 26.863281 29.6875 25 29.6875 C 23.136719 29.6875 21.875 28.425781 21.875 26.5625 L 21.875 23.4375 C 21.875 21.574219 23.136719 20.3125 25 20.3125 Z M 25 20.3125 "/>
  </g>
</svg>

and I delete the last Z M 25 20.3125 in d and generate successfully but loss some stroke
How to fix this problem?
Please help me >< Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants