Page MenuHome

SVG Import scaling is wrong on some files
Open, NormalPublic


Blender Version
2.78a, e8299c8

Short description of error
SVG files with viewBox attribute that differ from with/height attributes are scaled wrong.

Exact steps for others to reproduce the error
Cteate SVG file with content below:

<svg width="1000mm" height="1000mm" viewBox="0 0 1 1">
        <path d=" 
            M  0.0,  0.0
            L  1.0,  0.0
            L  1.0,  1.0
            L  0.0,  1.0

And then import it with File -> Import -> Scalable Vector Graphics (.svg). It is expected that the square will be 1x1 Blender units, but it's 3543x3543 Blender units.

That is because scaling is performed twice in SVGMatrixFromNode() function in file.

I don't quite understand what's happening during the function and why first scaling is needed, but I've made a "patch" that, I believe, kinda solves the issue. I may be totally wrong with this solution =)



Event Timeline

Vuk Gardašević (lijenstina) triaged this task as Normal priority.Nov 23 2016, 11:06 AM

I did an import on the generated SVG file with the code from the example and the scale seems off.

@Sergey Sharybin (sergey) when you have time, can you look into it. Thanks. :)

@Real Name (uvx3), can you submit diff in an unified format (o even better, diff generated by git diff) ?

Real Name (uvx3) added a comment.EditedNov 24 2016, 10:17 AM

Sorry for the wrong diff format.

Here's an output of diff -u.

It's strange, but I cant attach the python file. Here's a link to the file I've uploaded to github.