StealthRaccoon

Hello,

I've tested the Inkscape to Spine Script to save some time. However, I never got a full functional export with any of my SVG files. The Export script creates the ./images folder and exports always only the first layer, then it stops and finishes with this error message within inkscape:
Traceback (most recent call last):
File "InkscapeToSpine.py", line 286, in <module>
effect.affect()
File "C:\Program Files\Inkscape\share\extensions/inkex.py", line 283, in affect
self.effect()
File "InkscapeToSpine.py", line 267, in effect
bbox = self.get_bounding_box(id)
File "InkscapeToSpine.py", line 131, in get_bounding_box
return float(x), float(y), float(width), float(height)
ValueError: could not convert string to float:
I followed the installation process only with the exception, that my extions folder is this one: "C:\Users\User\AppData\Roaming\inkscape\extensions"

I tried to reinstall the extension. Due to the error message it seems to be an Error with the script.
I also tried several modifications in inkscape (export only paths, no paths, changing document size ...)

Hope for a fix soon, thank you!

(Used Script: https://github.com/EsotericSoftware/spine-scripts/tree/master/inkscape)
StealthRaccoon
  • Beiträge: 2

Erikari

The inkscape export works nicely for me with multiple layers, (I tested it with some SVGs I had around placed on different layers)

The folder you indicated is empty on my pc, I instead placed the files here:
C:\Program Files\Inkscape\share\extensions

Does it let you down even with basic shapes? Have you tried the illustrator exporter maybe?
Benutzeravatar
Erikari

Erikari
  • Beiträge: 2006

StealthRaccoon

I tried to move the files to the folder you mentioned and deleted the files from the first one. Inkscape seems to recognize scripts in both folders. However, the same problem still appears. Looking at the error message there is somehow a String value where a float value is expected. But I'm not sure why there is a String value at all. I'll try later some coding and fixing the script on my own.

Yes, even with a single rectangle object and nothing else. Honestly, I'm used to inkscape and will stay there, especially because it's open source. I do not want to buy illustrator just to do a fast export.

---

Okay, I did some coding and found something possibly helpful out:
I replaced this line (line 131)
return float(x), float(y), float(width), float(height)
with this one:
try:
return float(x), float(y), float(width), float(height)
except:
exit(x)
and tested all values. Surprisingly they are all empty Strings "".
I replaced the code later with:
try:
return float(x), float(y), float(width), float(height)
except:
return float(0), float(0), float(100), float(100)
and got a functional export. However, all images are thrown into the center of spines coordinate system. Of course that's no benefit, but at least the image export works now. Only the JSON Output has to be fixed now. I hope you have some idea, what might causes the error at all?
StealthRaccoon
  • Beiträge: 2

enginustun

Hi there,

I faced the same issue here and I changed line 124 in InkscapeToSpine.py
for k in ("x", "y", "width", "height"):
stdin.append("--file=%r --query-id=%r --query-%s" % (self.svg_file, id, k)) # line 124
stdin.append("") # For the last command
turned into
for k in ("x", "y", "width", "height"):
stdin.append("--file=%r --query-id=%s --query-%s " % (self.svg_file, id, k)) # line 124
stdin.append("") # For the last command
I changed --query-id=%r with --query-id=%s in line 124 and it seems working good now.
Because previous version generates --query-id=u'layer1' and it throws an error while executing as stdin.

I hope it helps.
enginustun
  • Beiträge: 1

Nate

Thanks! I've made the change in the spine-scripts Git repository.
Benutzeravatar
Nate

Nate
  • Beiträge: 9284


Zurück zu Bugs