Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by Kunda1 »

issue #3420 - SVG imports from inkscape lead to wrong dimensions
Bug was first isolated thanks to the german FreeCAD contingent ;) in https://forum.freecadweb.org/viewtopic.php?f=13&t=27344
With the change from 0.91 to 0.92 inkscape devs changed the conversion factor of userunit (uu) and mm. Pre-0.92 it was 1uu=1 inch/90 and starting from 0.92 it is 1 uu=1inch/96. This was necessary to meet the actual recommendations/rules of svg-standard and css. See article in inkscapewiki for further reading.

When a user creates a file in inkscape with absolute dimensions (mm) and saves it, then imports it into FC, bodies in Freecad come out with too large dimensions. For example - a 100mm square will be 106,66mm in FC now (100 x 96/90).
Example SVGs are available in the ticket
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by Kunda1 »

Will there be a need to make an import pop-up asking if the user wants pre-Inkscape0.92 or post-Inkscape0.92 compatibility?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
PrzemoF
Veteran
Posts: 3515
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by PrzemoF »

Maybe we could use the version stored in the actual SVG file?

Code: Select all

inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
chrisb
Veteran
Posts: 51226
Joined: Tue Mar 17, 2015 9:14 am

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by chrisb »

Kunda1 wrote: Fri Jun 28, 2019 10:41 am Will there be a need to make an import pop-up asking if the user wants pre-Inkscape0.92 or post-Inkscape0.92 compatibility?
No, I don't think so. It is all going to the newer versions, in FreeCAD as well as in Inkscape. When 0.19 becomes stable even more people use newer inkscapes, probably 1.0.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by Kunda1 »

PrzemoF wrote: Fri Jun 28, 2019 12:57 pm Maybe we could use the version stored in the actual SVG file?

Code: Select all

inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
Hey @PrzemoF, would you mind elaborating how that could be useful?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
PrzemoF
Veteran
Posts: 3515
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by PrzemoF »

I hope I don't miss something obvious :D
- in inkscape up to Pre-0.92 it was 1 uu=1 inch/90
- in inkscape starting from 0.92 it is 1 uu=1 inch/96
- SVG file created by inkscape contains a line like this:

Code: Select all

inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
So by checking the version of inkscape that saved the actual SVG file you can tell what should the conversion factor.
openBrain
Veteran
Posts: 8997
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by openBrain »

Given that the second (96 DPI) should be the standard. :P
Actually maybe a better algorithm is "SVG is 96 DPI except for Inkscape < 0.92 where it's 90 DPI". ;)
Hope this is the current behavior. :)
User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by Kunda1 »

Hey @wandererfan, could you weigh in on this? How are we evaluating SVG's currently ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
wandererfan
Veteran
Posts: 5870
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by wandererfan »

Kunda1 wrote: Thu Jul 04, 2019 10:45 pm Hey @wandererfan, could you weigh in on this? How are we evaluating SVG's currently ?
Geometry imports are done by Draft.importSVG.py and it has 90 ppi hard coded in a number of places.

Drawing and TD don't seem to consider ppi at all, just user units.
User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3420 - SVG imports from inkscape lead to wrong dimensions

Post by Kunda1 »

Looks like it's in the getsize() function: https://github.com/FreeCAD/FreeCAD/blob ... VG.py#L263
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply