Getting the ID of the selection in a Python script for Inkscape.
I was wondering how to obtain the current selection from within an Inkscape script written in Python. I note that the getselected method in the inkex.py file contains a comment that says it "Collect selected nodes". Does this mean that it only returns the nodes from the selection? Does it return the DOM representation of the selection?
What is the quickest way, if it is even possible, to obtain the current selection in Inkscape from a python script? I'm thinking maybe I can get an id of the selection with a helper method an then use some methods in to get the DOM element of the selection using the "id" attribute.
I hope my question makes sense. I've been trying to read through some of the material online about writing scripts and/or extensions for Inkscape, but I must admit it is a little confusing for me. I appreciate your patient assistance.
I will do my best to post a summary of any responses to this question on the Inkscape wiki if that would help other future script writers. :]
Scott Huey
On Wed, 2007-10-03 at 21:40 -0700, Redefined Horizons wrote:
I was wondering how to obtain the current selection from within an Inkscape script written in Python. I note that the getselected method in the inkex.py file contains a comment that says it "Collect selected nodes". Does this mean that it only returns the nodes from the selection? Does it return the DOM representation of the selection?
What happens in that the script is given the XML document and a list of id's for the selections. So it would look something like this if it was called on the commandline:
python myscript.py --id=node243 old_doc.svg > new_doc.svg
The inkex.py wrapper turns all of this into my "python like" objects providing DOM and lists of the selected nodes.
--Ted
participants (2)
-
Redefined Horizons
-
Ted Gould