SVG import questions.

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

SVG import questions.

nophead
When I export a simple shape centered around the origin in SVG format and then import it again it comes in with an offset, different for X and Y.

image.png
If I import it into InkScape it ends up with a corner at the origin.

image.png

Is there no standard for interpreting the coordinates?

Another problem I have is when I import a panel with holes that was made from a PDF using InkScape it imports outlines instead of a solid.

image.png

What determines if a path is interpreted as an outline of a polygon or a stroke with finite width?




_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
dpa
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

dpa

Hi nop.head,
first question:
I don't have an answer but importing the SVG into Inkscape and looking for  "Document Properties.." looks like this (what is strange):
Bildschirmfoto 2020-06-18 um 17.01.16.png
In the Scale/Viewbox section is set X and Y = -10 what should be both =0
That is the reason for the offset. I think that's a bug in OpenSCAD export.
And a minor thing: I have the Display Units always set to "mm". The SVG-export from OpenSCAD should do that too.


About your second question:
I don't know what caused the form you showed but if I read "PDF".. well.. I think that's complicated and pretty error-like.
Maybe there are several equal forms on top of each other?

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

nophead
I found this definition of viewBox:

The viewBox attribute defines the position and dimension, in user space, of an SVG viewport. 
The value of the viewBox attribute is a list of four numbers: min-xmin-ywidth and height. The numbers separated by whitespace and/or a comma, which specify a rectangle in user space which is mapped to the bounds of the viewport established for the associated SVG element
 
That seems to be correct because the object starts and -10,-10 and is 20 wide. So it looks more like InkScape and the SVG import are both wrong.

Perhaps the PDF is not simply a line drawing, i.e. the lines are actually thin filled rectangles rather than a line with stroke.



On Thu, 18 Jun 2020 at 16:51, dpa <[hidden email]> wrote:

Hi nop.head,
first question:
I don't have an answer but importing the SVG into Inkscape and looking for  "Document Properties.." looks like this (what is strange):
Bildschirmfoto 2020-06-18 um 17.01.16.png
In the Scale/Viewbox section is set X and Y = -10 what should be both =0
That is the reason for the offset. I think that's a bug in OpenSCAD export.
And a minor thing: I have the Display Units always set to "mm". The SVG-export from OpenSCAD should do that too.


About your second question:
I don't know what caused the form you showed but if I read "PDF".. well.. I think that's complicated and pretty error-like.
Maybe there are several equal forms on top of each other?
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

Troberg
In reply to this post by nophead
I've been importing and exporting SVG files, using OpenSCAD, InkScape,
Scribus, LightBurn and a few other tools a lot recently, and it seems to me
that the file itself has no origin, at least not that any of them care
about, they all just use their own method (usually center, bottom left or
top left).



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

nophead
Well the viewport is supposed to give the origin indirectly, OpenSCAD seems to set it correctly on export but interprets it wrongly on import. I am surprised there isn't a test in the test suite that notices.

InkScape does seem to ignore it and makes the bottom left the origin. Also if I convert it to DXF with https://cloudconvert.com/ it also puts the bottom left on the origin.

It is probably a mess because SVG is designed to represent pictures, not CAD data. I think OpenSCAD should be consistent with itself though.

On Thu, 25 Jun 2020 at 10:54, Troberg <[hidden email]> wrote:
I've been importing and exporting SVG files, using OpenSCAD, InkScape,
Scribus, LightBurn and a few other tools a lot recently, and it seems to me
that the file itself has no origin, at least not that any of them care
about, they all just use their own method (usually center, bottom left or
top left).



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
dpa
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

dpa
In reply to this post by Troberg
I work with inkscape and have a setting (Viewbox X and Y=0, as I mentioned here before) which is exactly what it should be!
The disadvantage is that the object is not made for "to look at".
Attached a simple circle around [0,0] with an unchanged document size (A4).
The preview (on mac) shows the 'empty' A4 sheet and I have to scroll down, at the bottom left you can see a quarter circle.
In Inkscape this is also in the lower left, just where [0,0] is. In OpenSCAD it is nicely centered, as expected with center at [0,0].
That's the thing about coordinates...

Am Do., 25. Juni 2020 um 11:54 Uhr schrieb Troberg <[hidden email]>:
I've been importing and exporting SVG files, using OpenSCAD, InkScape,
Scribus, LightBurn and a few other tools a lot recently, and it seems to me
that the file itself has no origin, at least not that any of them care
about, they all just use their own method (usually center, bottom left or
top left).



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

circle_around_origin[0,0].svg (2K) Download Attachment
dpa
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

dpa
..so OpenSCAD import is fine.
I think OpenSCAD exports in a way for better "look at", moves the content to >=0 (by adding some View x,y to it) so that the content appears on the "light side"
If you import the attached svg in OpenSCAD and export it back to svg and open it elsewhere you can see what I mean.

Am Do., 25. Juni 2020 um 17:47 Uhr schrieb dpa <[hidden email]>:
I work with inkscape and have a setting (Viewbox X and Y=0, as I mentioned here before) which is exactly what it should be!
The disadvantage is that the object is not made for "to look at".
Attached a simple circle around [0,0] with an unchanged document size (A4).
The preview (on mac) shows the 'empty' A4 sheet and I have to scroll down, at the bottom left you can see a quarter circle.
In Inkscape this is also in the lower left, just where [0,0] is. In OpenSCAD it is nicely centered, as expected with center at [0,0].
That's the thing about coordinates...

Am Do., 25. Juni 2020 um 11:54 Uhr schrieb Troberg <[hidden email]>:
I've been importing and exporting SVG files, using OpenSCAD, InkScape,
Scribus, LightBurn and a few other tools a lot recently, and it seems to me
that the file itself has no origin, at least not that any of them care
about, they all just use their own method (usually center, bottom left or
top left).



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

nophead
So basically you can't display anything with negative coordinates without shifting it in SVG?

The OpenSCAD export coordinates range from -10 to +10. The viewBox starts at -10 and has an extent of 20, which seems correct to me. I would expect to see the full circle, not a quarter, but I don't expect the circle to be moved. I expect the viewPort to range from -10 to plus 10 and the circle stay on the origin in InkScape. 

OpenSCAD has an infinite viewport, so I think it should ignore the viewBox on import. I have no idea why it doesn't treat X and Y the same either.

On Thu, 25 Jun 2020 at 16:59, dpa <[hidden email]> wrote:
..so OpenSCAD import is fine.
I think OpenSCAD exports in a way for better "look at", moves the content to >=0 (by adding some View x,y to it) so that the content appears on the "light side"
If you import the attached svg in OpenSCAD and export it back to svg and open it elsewhere you can see what I mean.

Am Do., 25. Juni 2020 um 17:47 Uhr schrieb dpa <[hidden email]>:
I work with inkscape and have a setting (Viewbox X and Y=0, as I mentioned here before) which is exactly what it should be!
The disadvantage is that the object is not made for "to look at".
Attached a simple circle around [0,0] with an unchanged document size (A4).
The preview (on mac) shows the 'empty' A4 sheet and I have to scroll down, at the bottom left you can see a quarter circle.
In Inkscape this is also in the lower left, just where [0,0] is. In OpenSCAD it is nicely centered, as expected with center at [0,0].
That's the thing about coordinates...

Am Do., 25. Juni 2020 um 11:54 Uhr schrieb Troberg <[hidden email]>:
I've been importing and exporting SVG files, using OpenSCAD, InkScape,
Scribus, LightBurn and a few other tools a lot recently, and it seems to me
that the file itself has no origin, at least not that any of them care
about, they all just use their own method (usually center, bottom left or
top left).



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

OpenSCAD mailing list-2
In reply to this post by dpa
This is one of those cases reading the manual has a value.

On 2020-06-25 11:47 a.m., dpa wrote:
I work with inkscape and have a setting (Viewbox X and Y=0, as I mentioned here before) which is exactly what it should be!
The disadvantage is that the object is not made for "to look at".
Attached a simple circle around [0,0] with an unchanged document size (A4).
The preview (on mac) shows the 'empty' A4 sheet and I have to scroll down, at the bottom left you can see a quarter circle.
In Inkscape this is also in the lower left, just where [0,0] is. In OpenSCAD it is nicely centered, as expected with center at [0,0].
That's the thing about coordinates...

Am Do., 25. Juni 2020 um 11:54 Uhr schrieb Troberg <[hidden email]>:
I've been importing and exporting SVG files, using OpenSCAD, InkScape,
Scribus, LightBurn and a few other tools a lot recently, and it seems to me
that the file itself has no origin, at least not that any of them care
about, they all just use their own method (usually center, bottom left or
top left).



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: SVG import questions.

nophead
The manual leads to here:  https://www.w3.org/TR/SVG/coords.html#ComputingAViewportsTransform

When I go through that algorithm I get translate(0, 0) scale(1,1) which should leave my geometry unchanged unless I am mistaken.

On Thu, 25 Jun 2020 at 17:57, Ron Wheeler via Discuss <[hidden email]> wrote:
This is one of those cases reading the manual has a value.

On 2020-06-25 11:47 a.m., dpa wrote:
I work with inkscape and have a setting (Viewbox X and Y=0, as I mentioned here before) which is exactly what it should be!
The disadvantage is that the object is not made for "to look at".
Attached a simple circle around [0,0] with an unchanged document size (A4).
The preview (on mac) shows the 'empty' A4 sheet and I have to scroll down, at the bottom left you can see a quarter circle.
In Inkscape this is also in the lower left, just where [0,0] is. In OpenSCAD it is nicely centered, as expected with center at [0,0].
That's the thing about coordinates...

Am Do., 25. Juni 2020 um 11:54 Uhr schrieb Troberg <[hidden email]>:
I've been importing and exporting SVG files, using OpenSCAD, InkScape,
Scribus, LightBurn and a few other tools a lot recently, and it seems to me
that the file itself has no origin, at least not that any of them care
about, they all just use their own method (usually center, bottom left or
top left).



--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

-- 
Ron Wheeler
Artifact Software
438-345-3369
[hidden email]
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org