Hello,
like shown in the title, I want to convert the coordinates i get from the plane SVG-File to the coordinates which are shown in Inkscape. I think the reason for the difference, is that the origin of ordinates in Inkscape is the bottom left corner of my sheet, while the origin in SVG is the top left. Is that always the case? Can i just multiply the y-coordinates with -1 and subtract 297? Does this work for any kind of object (rect and path) even when I "paint" outside of the DIN A4 page as long as the format is still DIN A4?
Thank you in advance
Vipr0
Converting Coordinates in plane SVG File to Coordinates in Inkscape
Re: Converting Coordinates in plane SVG File to Coordinates in Inkscape
Hi,
Did you find any solution ? I have the same problem as you, And so far i can't find any solution how to do it.
Did you find any solution ? I have the same problem as you, And so far i can't find any solution how to do it.
Re: Converting Coordinates in plane SVG File to Coordinates in Inkscape
I am not an expert on SVG, but after working on CAD files for the past 2 years, I have an understanding of graphics systems.
I have been investigating the SVG files for the past few weeks.
If you look at https://www.w3.org/TR/SVG/coords.html the SVG spec, there are different "coordinate spaces" in the SVG file.
The <svg> element has something called a "viewbox".
This viewbox has an X, Y, Width and Height and does appear to have the X,Y at top left on the page.
The Width and height are defined by the page units times page scale (defined in the document properties dialog).
For instance, my page is 6 inches by 6 inches and my scale is 1000 "user units"
So, my viewbox is 0, 0, 6000, 6000.
When I draw a line from the lower left corner (displayed as 0,0) it is stored in the XML as 0, 6000.
So to answer your question, for the Y axis ...
absolute Y coordinate = viewbox height - Yvalue
relative Y coordinate = Yvalue * -1
This is still in user units, to convert both X and Y to actual displayed units, divide by the page scale.
Inkscape appears to have some problems with rounding errors (my actual path string is d="m 0,6000.0002 1000,-1000")
Also, inkscape seems to add random translate transforms which don't make any sense. You'll need to parse and use those as well.
I have been investigating the SVG files for the past few weeks.
If you look at https://www.w3.org/TR/SVG/coords.html the SVG spec, there are different "coordinate spaces" in the SVG file.
The <svg> element has something called a "viewbox".
This viewbox has an X, Y, Width and Height and does appear to have the X,Y at top left on the page.
The Width and height are defined by the page units times page scale (defined in the document properties dialog).
For instance, my page is 6 inches by 6 inches and my scale is 1000 "user units"
So, my viewbox is 0, 0, 6000, 6000.
When I draw a line from the lower left corner (displayed as 0,0) it is stored in the XML as 0, 6000.
So to answer your question, for the Y axis ...
absolute Y coordinate = viewbox height - Yvalue
relative Y coordinate = Yvalue * -1
This is still in user units, to convert both X and Y to actual displayed units, divide by the page scale.
Inkscape appears to have some problems with rounding errors (my actual path string is d="m 0,6000.0002 1000,-1000")
Also, inkscape seems to add random translate transforms which don't make any sense. You'll need to parse and use those as well.
- flamingolady
- Posts: 687
- Joined: Wed Jun 10, 2009 1:40 pm
Re: Converting Coordinates in plane SVG File to Coordinates in Inkscape
EddieRich,
In your example, how do you know that your scale is 1000 "user units"? Does that number change? From the very tiny bit that I can find on viewpoint, seems like it might. Is the user unit the pixels number of your page height? I have a similar issue as the OP (will need to export a font) using viewpoint (and have never used it).
dee
EddieRich wrote:The Width and height are defined by the page units times page scale (defined in the document properties dialog).
For instance, my page is 6 inches by 6 inches and my scale is 1000 "user units"
So, my viewbox is 0, 0, 6000, 6000.
In your example, how do you know that your scale is 1000 "user units"? Does that number change? From the very tiny bit that I can find on viewpoint, seems like it might. Is the user unit the pixels number of your page height? I have a similar issue as the OP (will need to export a font) using viewpoint (and have never used it).
dee
Re: Converting Coordinates in plane SVG File to Coordinates in Inkscape
flamingolady wrote:EddieRich,
In your example, how do you know that your scale is 1000 "user units"? Does that number change?
dee
I am using version 0.92, but it was the same in 0.91.
In the document properties dialog, page tab, under custom size, there is a scale section.
If you click the + next to the word viewbox, you can see/set the viewbox.
Normally, you would only set the X scale and Y will be the same.
I have found if you set the scale to high, the SVG paths start getting rounding errors.
Re: Converting Coordinates in plane SVG File to Coordinates in Inkscape
That part of the dialog is actually new in 0.92 and does not exist in 0.91.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)
Inkscape FAQ - Learning Resources - Website with tutorials (German and English)