[Draft] [bug #6653] SVG import does not work with plain SVG
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
[Draft] [bug #6653] SVG import does not work with plain SVG
As I wrote initially here: https://forum.freecadweb.org/viewtopic. ... 42#p582142
The SVG import has a bug:
- take this plain SVG of a box (created using Inkscape 1.1 and then saved as "Plain SVG"): and import it as SVG
result:
- you get an "error" about a missing DPI setting. However the settings are the SVG (as in the SVG specs it contains the mm settings).
Here is the issue: https://github.com/FreeCAD/FreeCAD/issues/6653
The SVG import has a bug:
- take this plain SVG of a box (created using Inkscape 1.1 and then saved as "Plain SVG"): and import it as SVG
result:
- you get an "error" about a missing DPI setting. However the settings are the SVG (as in the SVG specs it contains the mm settings).
Here is the issue: https://github.com/FreeCAD/FreeCAD/issues/6653
Re: [bug #6653] SVG import does not work with plain SVG
1. Downloaded svg
2. opened SVG in inkscape and exported to plain SVG
3. opened FC
4. Imported as SVG
Result: 6. Chose 'No' to keep 90 dpi
Result: Import in to FC but outputs the following:
2. opened SVG in inkscape and exported to plain SVG
3. opened FC
4. Imported as SVG
Result: 6. Chose 'No' to keep 90 dpi
Result: Import in to FC but outputs the following:
Code: Select all
07:49:35 This SVG file does not appear to have been produced by Inkscape. If it does not contain absolute units then a DPI setting will be used.
07:49:35 Do you wish to use 96 dpi? Choosing 'No' will use the older standard 90 dpi.
07:49:35 *** User specified 90.0 dpi ***
07:49:35 name: svg1061
07:49:35 done processing element 1
07:49:35 processing element 2: defs
07:49:35 existing group transform: [Matrix ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))]
07:49:35 name: defs1058
07:49:35 done processing element 2
07:49:35 processing element 3: g
07:49:35 existing group transform: [Matrix ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))]
07:49:35 name: layer1
07:49:35 done processing element 3
07:49:35 processing element 4: rect
07:49:35 existing group transform: [Matrix ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)), Matrix ((1,0,0,-59.2622),(0,1,0,102.273),(0,0,1,0),(0,0,0,1))]
07:49:35 name: rect1144
07:49:35 applying group transform: Matrix ((1,0,0,-59.2622),(0,1,0,102.273),(0,0,1,0),(0,0,0,1))
07:49:35 applying group transform: Matrix ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))
07:49:35 Loading GUI of Part module... done
07:49:35 done processing element 4
07:49:35 closing group
07:49:35 closing group
Code: Select all
OS: Ubuntu Core 20 (KDE/plasma)
Word size of FreeCAD: 64-bit
Version: 0.20.28342 (Git)
Build type: Release
Branch: master
Hash: 05a8b67dce165745310b12de565c9dfb5f632292
Python 3.8.10, Qt 5.15.3, Coin 4.0.0, OCC 7.6.1
Locale: C/Default (C)
Installed mods:
* ToolbarStyle
* Assembly4 0.11.10
* stickframe
* sheetmetal 0.2.49
* Assembly3 0.11.0
* Behave-Dark-Colors 0.0.1
* Curves 0.3.0
* Ship
* BIM 2021.12.0
* A2plus 0.4.55
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
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
- wandererfan
- Veteran
- Posts: 6268
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [bug #6653] SVG import does not work with plain SVG
This isn't a TD bug. "Insert SVG Symbol" accepts plain SVG. The error messages come when importing as geometry or importing to Drawing WB.
The messages are produced by Draft/importSVG.py.
The messages are produced by Draft/importSVG.py.
Re: [bug #6653] SVG import does not work with plain SVG
Thanks. I moved the topic to the Help forum and labeled it accordingly.
Inviting Roy since he knows Draft well.
Roy_043 wrote: .
Re: [Draft] [bug #6653] SVG import does not work with plain SVG
I do not know the SVG format, nor the FreeCAD code involved. Maybe Yorik can assist.
yorik wrote: pinged by pinger macro
Re: [Draft] [bug #6653] SVG import does not work with plain SVG
The "test" for inkscape DPI happens here: https://github.com/FreeCAD/FreeCAD/blob ... VG.py#L731
The way I see it, if no "inkscape:version" attribute is found in the <svg> element, the message is printed. Obviously if you saved it as plain SVG, that attribute is not there anymore, and the message is printed.
Now, in your file, only the svg box size is in mm. All the other values are unitless. That's a problem. The way I understand it, you can mix units in an SVG file. So can we assume that if the view box has units, all other values of the file are to be considered of the same unit?
Maybe instead of a yes/no dialog, we need to allow users to enter a custom value, so you could write "90 dots per inch" or "1 unit per mm" which would be applied to all unitless or px values
The way I see it, if no "inkscape:version" attribute is found in the <svg> element, the message is printed. Obviously if you saved it as plain SVG, that attribute is not there anymore, and the message is printed.
Now, in your file, only the svg box size is in mm. All the other values are unitless. That's a problem. The way I understand it, you can mix units in an SVG file. So can we assume that if the view box has units, all other values of the file are to be considered of the same unit?
Maybe instead of a yes/no dialog, we need to allow users to enter a custom value, so you could write "90 dots per inch" or "1 unit per mm" which would be applied to all unitless or px values
Re: [Draft] [bug #6653] SVG import does not work with plain SVG
This is the issue. Inskscape is by definition just a SVG editor. Its specialties should not count. So no matter if there are Inkscape specifications or note, the SVG should be read according to the SVG specs.yorik wrote: ↑Mon Mar 28, 2022 1:09 pm The "test" for inkscape DPI happens here: https://github.com/FreeCAD/FreeCAD/blob ... VG.py#L731
The way I see it, if no "inkscape:version" attribute is found in the <svg> element, the message is printed. Obviously if you saved it as plain SVG, that attribute is not there anymore, and the message is printed.
According to the SVG specs:yorik wrote: ↑Mon Mar 28, 2022 1:09 pm Now, in your file, only the svg box size is in mm. All the other values are unitless. That's a problem. The way I understand it, you can mix units in an SVG file. So can we assume that if the view box has units, all other values of the file are to be considered of the same unit?
https://www.w3.org/TR/SVG2/coords.html# ... nateSystem
you declare the unit once. In the SVG specis they have this example
Code: Select all
<svg width="300px" height="100px" version="1.1"
in my SVG I have:
Code: Select all
<svg width="97.434448mm" height="99.698174mm" viewBox="0 0 97.434448 99.698174" version="1.1"...
There should not be a dialog at all, because the file defines the unit already according to the SVG specs.
Re: [Draft] [bug #6653] SVG import does not work with plain SVG
What about those users who have old SVG files as per https://github.com/FreeCAD/FreeCAD/issues/5781 , surely there needs to be some consideration to not just the latest and greatest versions/specifications.
Re: [Draft] [bug #6653] SVG import does not work with plain SVG
SVG 1.1 was released 10 years ago (sic!)Syres wrote: ↑Mon Mar 28, 2022 4:13 pm What about those users who have old SVG files as per https://github.com/FreeCAD/FreeCAD/issues/5781 , surely there needs to be some consideration to not just the latest and greatest versions/specifications.
My opinion is that we should be independent on certain 3rdparty programs like Inkscape. And since the Inkscape issue was fixed more than 4 years ago, I don't think we should care for it anymore. If you don't agree, then the dialog should only appear when users input an old Inkscape SVG.
As reference here are 3 versions of the same SVG:
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: [Draft] [bug #6653] SVG import does not work with plain SVG
I'm not sure I understand that issue, but Inkscape is free software, anyone can get it, if you have an old incorrect inkscape file, fix it in inkscape (I think by just oppening it already prompts you to fix the dpi) and then import in FreeCAD. IMO FreeCAD doesn't have the responsibility to support inkscape's old incorrect output. And regarding the example one user posted that specified a unit and no inkscape dpi, I think that's the kind of svg that uwe wants to add support.Syres wrote: ↑Mon Mar 28, 2022 4:13 pm What about those users who have old SVG files as per https://github.com/FreeCAD/FreeCAD/issues/5781 , surely there needs to be some consideration to not just the latest and greatest versions/specifications.