return [kind(val) for val in string.replace(',', ' ').replace('-', ' -').replace('e ', 'e').split()] ValueError: could not convert string to float
Opened this issue · 7 comments
Steps to reproduce:
Open SVG in the Inkscape 1.0.2
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 459.75 385.83">
<g id="test">
<path class="cls-1"
d="M4917.86,4893.09c-64.49.89-159.87,67.81-132.49,141.92,12.84,34.73,56.12,39.55,86.66,24.12,32-16.17,52.86-49.24,68.56-79.6,10.53-20.39,26.46-53.24,8.8-74.07C4941.93,4896.66,4929.58,4892.93,4917.86,4893.09Z"
transform="translate(-4732.62 -4684.06)"/>
</g>
</svg>
and run this extension (taken from the master branch).
Actual result:
Traceback (most recent call last):
File "applytransform.py", line 160, in <module>
ApplyTransform().run()
File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/base.py", line 140, in run
self.save_raw(self.effect())
File "applytransform.py", line 25, in effect
self.recursiveFuseTransform(self.document.getroot())
File "applytransform.py", line 157, in recursiveFuseTransform
self.recursiveFuseTransform(child, transf)
File "applytransform.py", line 157, in recursiveFuseTransform
self.recursiveFuseTransform(child, transf)
File "applytransform.py", line 73, in recursiveFuseTransform
p = CubicSuperPath(d)
File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/paths.py", line 1325, in __init__
items = Path(items)
File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/paths.py", line 1086, in __init__
for item in (path_d or ()):
File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/paths.py", line 1102, in parse_string
args = list(strargs(numbers))
File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/utils.py", line 187, in strargs
return [kind(val) for val in string.replace(',', ' ').replace('-', ' -').replace('e ', 'e').split()]
File "/Applications/Inkscape.app/Contents/Resources/share/inkscape/extensions/inkex/utils.py", line 187, in <listcomp>
return [kind(val) for val in string.replace(',', ' ').replace('-', ' -').replace('e ', 'e').split()]
ValueError: could not convert string to float: '-64.49.89'
Expected result:
transforms are removed
hi,
your XML is valid by official W3 terms but your path contains an error-prone number, which is -64.49.89. You need to correct this manually. You won't able to run a lot of other extensions too on this path. If you have had created the path with a regular SVG editor ,such coordinate would not have been created i guess.
cheers, Mario
hmm interesting. i did not know that. but the issue cannot be resolved by apply transforms extension. the inkex extensions need to be adjusted at central place to support that. as i see your fix contains this. so it seems you use an inkscape version which does not contain your own fix yet
Just FYI, I had the same issue with an svg generated by adobe illustrator so it does seem to be a widely used spec
Opened a backport MR https://gitlab.com/inkscape/extensions/-/merge_requests/385, maybe we can get it to 1.1.2.
Thanks for the backport MR. Hopefully, this gets through! 🤞🏻
Yeah, it is part of 1.1.2.