Change layer or selection from within extension

Discussion about writing code for Inkscape.
g99k
Posts: 3
Joined: Mon Dec 14, 2009 5:24 am

Change layer or selection from within extension

Postby g99k » Thu Apr 12, 2012 6:28 am

Hi everyone!

Does anyone know if it is somehow possible to change the selection or the active layer from within an Inkscape Python extension?

I couldn't find anything like that in the extensions shipped with Inkscape. Also, the Inkscape multipage extension uses a real weird workaround for page navigation: instead of using layers for pages, all pages are stored "offline" in an invisible element and are swapped into a single layer for viewing or editing.

This probably means that it's not possible, but I just thought it'd be safer to ask.

Many thanks for an answer!

g99k
Posts: 3
Joined: Mon Dec 14, 2009 5:24 am

Re: Change layer or selection from within extension

Postby g99k » Fri Apr 13, 2012 4:06 am

Never mind, I think I found the solution myself. :D

I just saw that you could change the current-layer attribute of the namedview element. It's not read by Inkscape after running an extension right now, but it says here that this is going to be fixed in the next release.

Alternatively, you can swap the id of the current layer into the layer that you want to select, as long as that id isn't referenced anywhere.


Return to “Programming”