discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

svg location error

RW
Raymond West
Fri, Jan 27, 2023 2:40 PM

If I generate an svg within openscad and reimport it, then it does not
appear in the original location. I think the viewbox parameters are
mis-calculated when exported. Any possibility of that being corrected?

OpenSCAD https://www.openscad.org/version 2022.11.18.ci12805 (git
1746d5a83)

If I generate an svg within openscad and reimport it, then it does not appear in the original location. I think the viewbox parameters are mis-calculated when exported. Any possibility of that being corrected? OpenSCAD <https://www.openscad.org/>version 2022.11.18.ci12805 (git 1746d5a83)
JB
Jordan Brown
Fri, Jan 27, 2023 6:02 PM

On 1/27/2023 6:40 AM, Raymond West wrote:

If I generate an svg within openscad and reimport it, then it does not
appear in the original location. I think the viewbox parameters are
mis-calculated when exported. Any possibility of that being corrected?

I duplicate the problem; I filed
https://github.com/openscad/openscad/issues/4514 .

It is not clear to me whether the problem is in the export or in the
import.  I expect that it is at least partially connected to the fact
that SVG likes +Y to go down the page, while OpenSCAD likes +Y to go up
the page.

On 1/27/2023 6:40 AM, Raymond West wrote: > > If I generate an svg within openscad and reimport it, then it does not > appear in the original location. I think the viewbox parameters are > mis-calculated when exported. Any possibility of that being corrected? > I duplicate the problem; I filed https://github.com/openscad/openscad/issues/4514 . It is not clear to me whether the problem is in the export or in the import.  I expect that it is at least partially connected to the fact that SVG likes +Y to go down the page, while OpenSCAD likes +Y to go up the page.
RW
Raymond West
Fri, Jan 27, 2023 7:20 PM

Thanks. If you edit the svg file, you can fix it so that it imports to
the correct place. It seems to import other svg files OK'ish, provided
the  boxview x, y is at more or less 0,0, afaik.   I tested it a few
times, the error depends on the size and location of the original
square/other shape.

For your example, the viewbox is  <svg width="10mm" height="10mm"
viewBox="10 -20 10 10"  . If it is 'corrected to '

<svg width="10mm" height="10mm" viewBox="0 10 10 10"  then it imports
correctly, but both may not be displayed in some svg viewers. (Irfan
View displays neither, but firefox and brave, for example displays the
original version.)

It may be necessary to  read the <title>OpenSCAD Model</title> to apply
the corrections on importing/whatever (or maybe insist the the image is
at 0,0, and apply a correction of  twice the height (not checked that,
however).

On 27/01/2023 18:02, Jordan Brown wrote:

On 1/27/2023 6:40 AM, Raymond West wrote:

If I generate an svg within openscad and reimport it, then it does
not appear in the original location. I think the viewbox parameters
are mis-calculated when exported. Any possibility of that being
corrected?

I duplicate the problem; I filed
https://github.com/openscad/openscad/issues/4514 .

It is not clear to me whether the problem is in the export or in the
import.  I expect that it is at least partially connected to the fact
that SVG likes +Y to go down the page, while OpenSCAD likes +Y to go
up the page.

Thanks. If you edit the svg file, you can fix it so that it imports to the correct place. It seems to import other svg files OK'ish, provided the  boxview x, y is at more or less 0,0, afaik.   I tested it a few times, the error depends on the size and location of the original square/other shape. For your example, the viewbox is  <svg width="10mm" height="10mm" viewBox="10 -20 10 10"  . If it is 'corrected to ' <svg width="10mm" height="10mm" viewBox="0 10 10 10"  then it imports correctly, but both may not be displayed in some svg viewers. (Irfan View displays neither, but firefox and brave, for example displays the original version.) It may be necessary to  read the <title>OpenSCAD Model</title> to apply the corrections on importing/whatever (or maybe insist the the image is at 0,0, and apply a correction of  twice the height (not checked that, however). On 27/01/2023 18:02, Jordan Brown wrote: > On 1/27/2023 6:40 AM, Raymond West wrote: >> >> If I generate an svg within openscad and reimport it, then it does >> not appear in the original location. I think the viewbox parameters >> are mis-calculated when exported. Any possibility of that being >> corrected? >> > > I duplicate the problem; I filed > https://github.com/openscad/openscad/issues/4514 . > > It is not clear to me whether the problem is in the export or in the > import.  I expect that it is at least partially connected to the fact > that SVG likes +Y to go down the page, while OpenSCAD likes +Y to go > up the page. >
JB
Jordan Brown
Fri, Jan 27, 2023 8:18 PM

The best place to put theories, analysis, and possible fixes is in the
issue comments at https://github.com/openscad/openscad/issues/4514 .

The best place to put theories, analysis, and possible fixes is in the issue comments at https://github.com/openscad/openscad/issues/4514 .
RW
Raymond West
Sat, Jan 28, 2023 11:42 AM

Having conducted a few more tests, object in different or all regions,
and it seems for openscad exported svg's , if you change the viewbox x
parameter to 0, and the y to the height, it seems to locate correctly on
import back into openscad, but it cannot then be viewed in firefox, etc.
with those changes.

On 27/01/2023 19:20, Raymond West wrote:

Thanks. If you edit the svg file, you can fix it so that it imports to
the correct place. It seems to import other svg files OK'ish, provided
the  boxview x, y is at more or less 0,0, afaik.   I tested it a few
times, the error depends on the size and location of the original
square/other shape.

For your example, the viewbox is  <svg width="10mm" height="10mm"
viewBox="10 -20 10 10"  . If it is 'corrected to '

<svg width="10mm" height="10mm" viewBox="0 10 10 10"  then it imports
correctly, but both may not be displayed in some svg viewers. (Irfan
View displays neither, but firefox and brave, for example displays the
original version.)

It may be necessary to  read the <title>OpenSCAD Model</title> to
apply the corrections on importing/whatever (or maybe insist the the
image is at 0,0, and apply a correction of  twice the height (not
checked that, however).

On 27/01/2023 18:02, Jordan Brown wrote:

On 1/27/2023 6:40 AM, Raymond West wrote:

If I generate an svg within openscad and reimport it, then it does
not appear in the original location. I think the viewbox parameters
are mis-calculated when exported. Any possibility of that being
corrected?

I duplicate the problem; I filed
https://github.com/openscad/openscad/issues/4514 .

It is not clear to me whether the problem is in the export or in the
import.  I expect that it is at least partially connected to the fact
that SVG likes +Y to go down the page, while OpenSCAD likes +Y to go
up the page.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Having conducted a few more tests, object in different or all regions, and it seems for openscad exported svg's , if you change the viewbox x parameter to 0, and the y to the height, it seems to locate correctly on import back into openscad, but it cannot then be viewed in firefox, etc. with those changes. On 27/01/2023 19:20, Raymond West wrote: > Thanks. If you edit the svg file, you can fix it so that it imports to > the correct place. It seems to import other svg files OK'ish, provided > the  boxview x, y is at more or less 0,0, afaik.   I tested it a few > times, the error depends on the size and location of the original > square/other shape. > > For your example, the viewbox is  <svg width="10mm" height="10mm" > viewBox="10 -20 10 10"  . If it is 'corrected to ' > > <svg width="10mm" height="10mm" viewBox="0 10 10 10"  then it imports > correctly, but both may not be displayed in some svg viewers. (Irfan > View displays neither, but firefox and brave, for example displays the > original version.) > > It may be necessary to  read the <title>OpenSCAD Model</title> to > apply the corrections on importing/whatever (or maybe insist the the > image is at 0,0, and apply a correction of  twice the height (not > checked that, however). > > > On 27/01/2023 18:02, Jordan Brown wrote: >> On 1/27/2023 6:40 AM, Raymond West wrote: >>> >>> If I generate an svg within openscad and reimport it, then it does >>> not appear in the original location. I think the viewbox parameters >>> are mis-calculated when exported. Any possibility of that being >>> corrected? >>> >> >> I duplicate the problem; I filed >> https://github.com/openscad/openscad/issues/4514 . >> >> It is not clear to me whether the problem is in the export or in the >> import.  I expect that it is at least partially connected to the fact >> that SVG likes +Y to go down the page, while OpenSCAD likes +Y to go >> up the page. >> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org