Determine Absolute Location of Object from SVG

Discuss SVG code, accessible via the XML Editor.
BigBird0000
Posts: 5
Joined: Sat Dec 13, 2014 3:02 am

Determine Absolute Location of Object from SVG

Postby BigBird0000 » Thu Aug 25, 2016 4:30 am

I am converted some old radio schematics to digital format.
I would like to be able to have a table of the different components each with the coordinates of where that component is on the schematic.
( Will be searching for the textual name of the component (ie C1 C2 -- C25 Or R1 R15 R26), and use coords of the text.
I would like to use VisualBasic dot Net or C# but will be willing to move to other languages if necessary.

Is there a way to get the absolute coordinates of an object reading the SVG?


Any Help Would Be Appreciated!
--alan

For example,
for component C25, I can find the Text:

<flowRoot
transform="matrix(1.8243866,0,0,1.8785325,-3894.3839,-587.48925)"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:25px;font-family:Arial;-inkscape-font-specification:'Arial Bold';text-align:start;text-anchor:start;opacity:1;fill:#ff0000;fill-opacity:1;stroke:#ff0000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.99337751"
id="flowRoot4439"
xml:space="preserve">
<flowRegion id="flowRegion4441">
<rect style="stroke:#ff0000;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.99337751" y="1718" x="2193" height="51" width="61" id="rect4443" />
</flowRegion>
<flowPara id="flowPara4445">C25</flowPara>
</flowRoot>

This is a view of what I am viewing in Inkscape (NOTE: Graphics and other info removed for simplicity)
C25_All.png
Inkscape View in Document
C25_All.png (63.82 KiB) Viewed 1354 times


Zoomed In View Of Coordinates
C25_WithBoundryLinesToGetCoord.png
Zoom View of C25
C25_WithBoundryLinesToGetCoord.png (61.84 KiB) Viewed 1354 times


The SVG is an attachment to this
Attachments
C25_SVG.svg
SVG written from Inkscape
(77.77 KiB) Downloaded 27 times

Moini
Posts: 2057
Joined: Mon Oct 05, 2015 10:44 am

Re: Determine Absolute Location of Object from SVG

Postby Moini » Thu Aug 25, 2016 7:18 am

You can either look into the selection tool's toolbar at the top of your Inkscape window to get a rough approximation, solve the equations yourself (involving matrix maths) or ask Inkscape to do it for you. If you need precision, I'd go for the latter:

inkscape yourfilename.svg --query-all --query-id yourobjectid

More info here:
https://inkscape.org/en/doc/inkscape-man.html

Lazur will be able to explain how to solve the matrix maths (you will need to take all groups into account that are 'around' the object whose position you'd like to know), if you want to do the maths yourself.
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)

Lazur
Posts: 4345
Joined: Tue Jun 14, 2016 10:38 am

Re: Determine Absolute Location of Object from SVG

Postby Lazur » Thu Aug 25, 2016 8:32 am

Well I'm not exactly sure what are you after but those texts are flowed and have a stroke set that may cause problems outside inksape.

BigBird0000
Posts: 5
Joined: Sat Dec 13, 2014 3:02 am

Re: Determine Absolute Location of Object from SVG

Postby BigBird0000 » Thu Aug 25, 2016 12:24 pm

Moini - thanks will check that out

Lazur: I just want to get a coordinate (x,y) of a point somewhere within the text object.
I am not going to use the SVG outside of inkscape - except for reading the XML to get the coordinate

Moini
Posts: 2057
Joined: Mon Oct 05, 2015 10:44 am

Re: Determine Absolute Location of Object from SVG

Postby Moini » Thu Aug 25, 2016 9:17 pm

If it is a text object, it may be necessary to convert it to a path to be able to select a specific letter (Path -> Object to Path). After this operation, the text will no longer be editable as text (if it was before).
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)

BigBird0000
Posts: 5
Joined: Sat Dec 13, 2014 3:02 am

Re: Determine Absolute Location of Object from SVG

Postby BigBird0000 » Fri Aug 26, 2016 4:32 am

Moini,
I am just looking for a "close" coordinate, the coordinates will be used to help find a component, so it is not necessary to have an
exact location for the text object.

Moini
Posts: 2057
Joined: Mon Oct 05, 2015 10:44 am

Re: Determine Absolute Location of Object from SVG

Postby Moini » Fri Aug 26, 2016 6:29 am

In that case, any of the mentioned methods will probably do :) If you need it to work programmatically, I'd suggest the (exact...) commandline method.
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)

BigBird0000
Posts: 5
Joined: Sat Dec 13, 2014 3:02 am

Re: Determine Absolute Location of Object from SVG

Postby BigBird0000 » Sat Aug 27, 2016 12:00 pm

Yes, the command line will work and provide me with coordinates.
I do need to take the viewbox into consideration, otherwise all is well!

Thank you guys!


Return to “SVG / XML Code”

Who is online

Users browsing this forum: No registered users and 1 guest