Unable to import svg. #70050

Closed
opened 2019-09-19 03:44:27 +02:00 by John McKeown · 8 comments

System Information
Operating system: Windows 10
Graphics card: N/A

Blender Version
Broken: 2.80
(example: 2.79b release)
(example: 2.80, edbf15d3c044, blender2.8, 2018-11-28, as found on the splash screen)
Worked: (optional)

Short description of error
Importing an SVG fails.
I wanted to make my own add-on for blender which would
render latex math formulas in blender using the approach documented here in the first answer:
https://blender.stackexchange.com/questions/72467/use-latex-in-blender

Instead of requiring add-on users to have latex and poppler-utils installed, I figured I could obtain
the SVG using this neat project: https://github.com/uetchy/math-api

However if I try to use the SVGs generated from that site, blender is not able to import them using the standard
svg importing addon.

Here's the traceback:

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\__init__.py", line 59, in execute
    return import_svg.load(self, context, filepath=self.filepath)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1934, in load
    load_svg(context, filepath, do_colormanage)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1925, in load_svg
    loader.createGeom(False)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1121, in createGeom
    self._doCreateGeom(instancing)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1173, in _doCreateGeom
    geom.createGeom(instancing)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1121, in createGeom
    self._doCreateGeom(instancing)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1817, in _doCreateGeom
    matrix = self.getNodeMatrix()
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1079, in getNodeMatrix
    return SVGMatrixFromNode(self._node, self._context)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 207, in SVGMatrixFromNode
    w = SVGParseCoord(node.getAttribute('width') or str(rect[0]), rect[0])
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 156, in SVGParseCoord
    token, last_char = SVGParseFloat(coord)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 112, in SVGParseFloat
    raise Exception('Invalid float value near ' + s[start:start + 10])
Exception: Invalid float value near 1.294ex

location: <unknown location>:-1


Here is the svg file's content:


<?xml version="1.0" standalone="no" ?>
  <!DOCTYPE svg PUBLIC "-*W3C*DTD SVG 1.0*EN" "http:*www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
  <svg style="vertical-align: -0.025ex" xmlns="http://www.w3.org/2000/svg" width="1.294ex" height="1.025ex" viewBox="0 -442 572 453"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="math"><g data-mml-node="mi"><path data-c="78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"></path></g></g></g></svg>

Exact steps for others to reproduce the errormySVG.svg
Based on the default startup or an attached .blend file (as simple as possible).

From the default startup import the attached file or any other generated from http://math.now.sh

**System Information** Operating system: Windows 10 Graphics card: N/A **Blender Version** Broken: 2.80 (example: 2.79b release) (example: 2.80, edbf15d3c044, blender2.8, 2018-11-28, as found on the splash screen) Worked: (optional) **Short description of error** Importing an SVG fails. I wanted to make my own add-on for blender which would render latex math formulas in blender using the approach documented here in the first answer: [[ https://blender.stackexchange.com/questions/72467/use-latex-in-blender ]] Instead of requiring add-on users to have latex and poppler-utils installed, I figured I could obtain the SVG using this neat project: [[ https://github.com/uetchy/math-api ]] However if I try to use the SVGs generated from that site, blender is not able to import them using the standard svg importing addon. Here's the traceback: ``` Traceback (most recent call last): File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\__init__.py", line 59, in execute return import_svg.load(self, context, filepath=self.filepath) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1934, in load load_svg(context, filepath, do_colormanage) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1925, in load_svg loader.createGeom(False) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1121, in createGeom self._doCreateGeom(instancing) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1173, in _doCreateGeom geom.createGeom(instancing) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1121, in createGeom self._doCreateGeom(instancing) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1817, in _doCreateGeom matrix = self.getNodeMatrix() File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 1079, in getNodeMatrix return SVGMatrixFromNode(self._node, self._context) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 207, in SVGMatrixFromNode w = SVGParseCoord(node.getAttribute('width') or str(rect[0]), rect[0]) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 156, in SVGParseCoord token, last_char = SVGParseFloat(coord) File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\addons\io_curve_svg\import_svg.py", line 112, in SVGParseFloat raise Exception('Invalid float value near ' + s[start:start + 10]) Exception: Invalid float value near 1.294ex location: <unknown location>:-1 ``` Here is the svg file's content: ``` <?xml version="1.0" standalone="no" ?> <!DOCTYPE svg PUBLIC "-*W3C*DTD SVG 1.0*EN" "http:*www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg style="vertical-align: -0.025ex" xmlns="http://www.w3.org/2000/svg" width="1.294ex" height="1.025ex" viewBox="0 -442 572 453"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)"><g data-mml-node="math"><g data-mml-node="mi"><path data-c="78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"></path></g></g></g></svg> ``` **Exact steps for others to reproduce the error**![mySVG.svg](https://archive.blender.org/developer/F7757247/mySVG.svg) Based on the default startup or an attached .blend file (as simple as possible). From the default startup import the attached file or any other generated from http://math.now.sh
Author

Added subscriber: @jackeown

Added subscriber: @jackeown

Added subscriber: @StephenSwaney

Added subscriber: @StephenSwaney

Don't know anything about SVG format, but width="1.294ex" doesn't look like valid Python floating point.

Don't know anything about SVG format, but width="1.294ex" doesn't look like valid Python floating point.

Added subscribers: @Sergey, @mont29

Added subscribers: @Sergey, @mont29
Sergey Sharybin was assigned by Bastien Montagne 2019-09-19 10:39:15 +02:00

Those are valid SVG units, see the specs… Looks like our importer expects unit-less values here, @Sergey think you are still maintaining that add-on?

Those are valid SVG units, see [the specs](https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#Length)… Looks like our importer expects unit-less values here, @Sergey think you are still maintaining that add-on?

This issue was referenced by cdf56b2fad

This issue was referenced by cdf56b2fade83eb8518dedcbdf137bc2d937407d

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

Wow! You guys are amazing!
Can't believe I just went to bed and woke up the next morning with this fixed!
Keep up the good work!

Wow! You guys are amazing! Can't believe I just went to bed and woke up the next morning with this fixed! Keep up the good work!
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#70050
No description provided.