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) lowered the priority of this task from Needs Triage by Developer to Normal.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.

@Brendon Murphy (meta-androcto), not sure why Howard is involved here. If this is still an issue the patch needs to be updated against latest sources.

@Sergey Sharybin (sergey) my mistake, I was looking at his addon in contrib

@Sergey Sharybin (sergey) was this fixed by rBAc2aef4a98f6c: SVG: Fix wrong closed path with quadratic segments?

@Brendon Murphy (meta-androcto), that sounds as an unrelated change, but there were other fixes related to this one, i.e. rBAb302fdf05355.

I've tried to import the demo SVN from this task and it shows as 1x1 plane, which is what the task description says is expected.
So my guess is that everything is working fine now.