SVG Import scaling is wrong on some files #50048

Closed
opened 2016-11-16 13:26:46 +01:00 by Real Name · 16 comments

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">
      <g>
          <path d=" 
              M  0.0,  0.0
              L  1.0,  0.0
              L  1.0,  1.0
              L  0.0,  1.0
              C
          "/>
      </g>
  </svg>

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 import_svg.py 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 =)

import_svg.diff

**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"> <g> <path d=" M 0.0, 0.0 L 1.0, 0.0 L 1.0, 1.0 L 0.0, 1.0 C "/> </g> </svg> ``` 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 `import_svg.py` 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 =) [import_svg.diff](https://archive.blender.org/developer/F401638/import_svg.diff)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @uvx3

Added subscriber: @uvx3

Added subscribers: @Sergey, @VukGardasevic

Added subscribers: @Sergey, @VukGardasevic

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

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

I did an import on the generated SVG file with the code from the example and the scale seems off. @Sergey when you have time, can you look into it. Thanks. :)

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

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

Sorry for the wrong diff format.

Here's an output of diff -u.

import_svg.diff

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

Sorry for the wrong diff format. Here's an output of `diff -u`. [import_svg.diff](https://archive.blender.org/developer/F405777/import_svg.diff) It's strange, but I cant attach the python file. Here's a [link to the file ](https://raw.githubusercontent.com/bb-q/scripts/master/import_svg.py) I've uploaded to github.
Member

Added subscribers: @howardt, @BrendonMurphy

Added subscribers: @howardt, @BrendonMurphy
Member

@howardt anything to do here?

@howardt anything to do here?

@BrendonMurphy, not sure why Howard is involved here. If this is still an issue the patch needs to be updated against latest sources.

@BrendonMurphy, not sure why Howard is involved here. If this is still an issue the patch needs to be updated against latest sources.
Member

@Sergey my mistake, I was looking at his addon in contrib

@Sergey my mistake, I was looking at his addon in contrib
Member

Removed subscriber: @howardt

Removed subscriber: @howardt
Member

@Sergey was this fixed by c2aef4a98f: SVG: Fix wrong closed path with quadratic segments?

@Sergey was this fixed by c2aef4a98f: SVG: Fix wrong closed path with quadratic segments?

@BrendonMurphy, that sounds as an unrelated change, but there were other fixes related to this one, i.e. b302fdf053.

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.

@BrendonMurphy, that sounds as an unrelated change, but there were other fixes related to this one, i.e. b302fdf053. 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.

Added subscriber: @iss

Added subscriber: @iss

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Richard Antalik self-assigned this 2020-02-14 22:43:02 +01:00

SVG file is imported as 1x1 plane now so I will assume this has been resolved.

If there are still any issues with scalig, please file new report

SVG file is imported as 1x1 plane now so I will assume this has been resolved. If there are still any issues with scalig, please file new report
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#50048
No description provided.