Retrieve a selected groups x, y coordinates?

Discussion about writing code for Inkscape.
draftman
Posts: 39
Joined: Sun Jan 25, 2015 5:29 am

Retrieve a selected groups x, y coordinates?

Postby draftman » Thu Jun 16, 2016 9:33 am

I'm making a python extension, and need the extension to retrieve a selected groups x, y coordinates.
I think this can be done with the bounding box, but I don't know how to do it.
if there's any other way of doing it I'm all ears.

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

Re: Retrieve a selected groups x, y coordinates?

Postby Moini » Fri Jun 17, 2016 8:37 am

Did you see the bounding box functions in simpletransform.py in the extensions directory? If it doesn't need to be 100% exact, you can use that. Else you can query the coordinates using the command line from inside the extension. There are many extensions that do this, but I can't give you a concrete example atm.
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)

draftman
Posts: 39
Joined: Sun Jan 25, 2015 5:29 am

Re: Retrieve a selected groups x, y coordinates?

Postby draftman » Fri Jun 17, 2016 2:06 pm

Hi Moini.
Yes I did see simpletransform / boxunion, roughBBox, refinedBBox.
I just don't know how to access it. Or what to access.
I'm guessing it should look something like this.

import simpletransform
bbox = simpletransform.refineBBox(node.get('path'))
x = bbox [0] [0] [1] [0]

And what is xmin, and xmax ?
Any help would be appreciated.

Thanks

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

Re: Retrieve a selected groups x, y coordinates?

Postby Moini » Sat Jun 18, 2016 9:24 am

Try with computeBBox instead ;-)

(which takes a list of objects, see it being used in, e.g., render_scale extension or export jpg extension:
https://github.com/brathering82/inkscape
https://github.com/giacmir/Inkscape-JPE ... -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)

draftman
Posts: 39
Joined: Sun Jan 25, 2015 5:29 am

Re: Retrieve a selected groups x, y coordinates?

Postby draftman » Sun Jun 19, 2016 6:14 am

Thanks, Moini.
I'll take a look at those extensions , and see if I can figure it out.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 6 guests