Coordinates of groups

Post questions on how to use or achieve an effect in Inkscape.
lukaszml
Posts: 3
Joined: Mon Nov 30, 2015 7:40 am

Coordinates of groups

Postby lukaszml » Mon Nov 30, 2015 7:57 am

Hello,
I have problem with Inkscape coordinate system.
I use inkscape as a UI desinger. I want export each group as a single svg and...I do it by python parser and inkscape commandline renderer.
But I have problem with coordinates of each object.
For example,
I have in inkscape group which is complete window deeper in group we have other group for example X (close) button, which construct by path, rectangle and ellipse

And parsers create tree of folders depend on <g></g>
When parser "see" <g></g> then create folder named <id of group> and go deeper until it encounters at <g root_img="true"></g> then all between <g....></g> treats as separate svg and call Inkscape commandline to render it, and save as <id of group>.png.

After all process I have.

Code: Select all

[folder]Window
   [image]close_btn.png
   [image]title_bar.png
   [folder]Products_list
      [image]product_belt1.png
      [image]product_belt3.png
      [image]product_belt2.png
   [folder]Advanced_options_window
      [image]hide_btn.png
      [image]title_aow_bar.png
      [folder]Options
         [image]opt1.png
         [image]opt2.png
         [image]opt3.png


I want now cooridnates.txt which have inside, for instance:

close_btn 1250, 10
title_bar 0, 0
product_belt1.png 150, 150
etc..

But how get absolute coordinates of each group ?

Someone have any idea ?


EDIT. It is possible to make plug-in which add additional arguments[x=150, y=120] to all groups in xml?

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Coordinates of groups

Postby v1nce » Mon Nov 30, 2015 9:01 am

It would help if you show us the svg

is your python script "svg aware" or is it just a text(=xml) parser ?

Javascript in modern browser should be able to give you the coordinates using methods as such as getBoundingClientRect.
Maybe there's the same for python ?
If not then you'd have to store (and parse) the coordinates of parent (and parent of ...) and to add them by yourself.
Or run a javascript to extract theme and "merge the resul"

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

Re: Coordinates of groups

Postby Moini » Mon Nov 30, 2015 9:27 am

Maybe it would make sense to create / adapt an extension for this?
The extension helper files simplepath and simpletransform (computeBBox) probably already do what you need here. And they are python, too ;)
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)

lukaszml
Posts: 3
Joined: Mon Nov 30, 2015 7:40 am

Re: Coordinates of groups

Postby lukaszml » Mon Nov 30, 2015 9:47 am

v1nce,
it just text-xml parser,

In Attachment I add svg which I use.
When I get this svg to my parser in return I got,

Code: Select all

[folder]window
   [image]window_bg.png
   [folder]title_bar
      [image]title_bar_bg.png
      [image]maximize_btn.png
      [image]minimize_btn.png
      [image]close_btn.png
      [image]title_txt.png


And now I need

window_bg 0,0
title_bar_bg 0, 1034.39
maximize_btn 1842.76, 1044.18
minimize_btn 1802.76, 1044.18
close_btn 1882.76, 1044.18
title_txt 24.68, 1043,55

as is in inkscape

Moini,

I want add inkscape coordinates of all group to XML svg <g></g> as attribute automaticly (example result <g id="title_bar_bg" x=0 y=1034.39>..content..</g>)
Where I find helper script doing similar operation which may me help
Attachments
wnd.svg
(5.24 KiB) Downloaded 218 times

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

Re: Coordinates of groups

Postby Moini » Mon Nov 30, 2015 11:06 am

You can find all extensions, including the helper files, in your extensions directory (in Inkscape, find it via: Shift+Ctrl+P (to open Preferences dialog), then look at System -> Inkscape extensions).
I can't help with how to use them (might be you need to use transformation matrices), as I've only started learning about this for my own, very humble extension.
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)

lukaszml
Posts: 3
Joined: Mon Nov 30, 2015 7:40 am

Re: Coordinates of groups

Postby lukaszml » Mon Nov 30, 2015 11:48 pm

How to execute simplepath.py in inkscape ?

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

Re: Coordinates of groups

Postby Moini » Tue Dec 01, 2015 4:52 am

Look at the other extensions, how they do it.
For more textbook-like info about how to write extensions, see here:
https://inkscape.org/en/develop/extensions/ and be sure to follow the links to the Wiki, too.
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)


Return to “Help with using Inkscape”