Shortcuts in inkscape extensions

Post questions on how to use or achieve an effect in Inkscape.
Nathan1123
Posts: 6
Joined: Wed May 20, 2015 3:16 am

Shortcuts in inkscape extensions

Postby Nathan1123 » Sat May 30, 2015 12:19 am

Hi,

I was trying to write my own extension, and I was wondering if it was at all possible to access shortcuts within the script. Specifically, Is there any way an inkscape extension can automatically select all objects in a given svg image? I know I can do it with ctrl+a but I was hoping there was a way of doing it automatically.

Thanks in advance,

Nathan

User avatar
Xav
Posts: 1209
Joined: Fri May 08, 2009 1:18 am
Location: UK
Contact:

Re: Shortcuts in inkscape extensions

Postby Xav » Sat May 30, 2015 1:14 am

My very limited understanding of Inkscape extensions - based on creating just one - is that they are external programs that are passed a complete copy of the XML, plus a collection of selected objects. They return a modified copy of the XML. There's no way that I could find to also return a selection, or to trigger any keyboard shortcuts within Inkscape itself.

Essentially an extension is a black box with XML fed in at one end, and XML coming out at the other end. There's not really any interaction with Inkscape itself, other than as a source and sink for the XML.
Co-creator of The Greys and Monsters, Inked - Inkscape drawn webcomics
Web SiteFacebookTwitter

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Shortcuts in inkscape extensions

Postby hulf2012 » Sat May 30, 2015 1:36 am

Xav wrote:My very limited understanding of Inkscape extensions - based on creating just one - is that they are external programs that are passed a complete copy of the XML, plus a collection of selected objects. They return a modified copy of the XML. There's no way that I could find to also return a selection, or to trigger any keyboard shortcuts within Inkscape itself.

Essentially an extension is a black box with XML fed in at one end, and XML coming out at the other end. There's not really any interaction with Inkscape itself, other than as a source and sink for the XML.


Xav, you are right... but in theory it's possible to have some access to some features of Inkscape using the command line"verbs" system

http://tavmjong.free.fr/INKSCAPE/MANUAL ... Query.html

Some extensions implement this feature (the export to synfig extension, if I'm not wrong)... but you have to code it. A better approach would if were just a module...I guess...
From time to time, this same topic is discussed here in the forum.
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.

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

Re: Shortcuts in inkscape extensions

Postby v1nce » Sat May 30, 2015 2:24 am

hulf2012 wrote:
Xav, you are right... but in theory it's possible to have some access to some features of Inkscape using the command line"verbs" system

http://tavmjong.free.fr/INKSCAPE/MANUAL ... Query.html

Some extensions implement this feature (the export to synfig extension, if I'm not wrong)... but you have to code it. A better approach would if were just a module...I guess...
From time to time, this same topic is discussed here in the forum.


I don't get it.
As Xav said the extension is called with the path of an xml file (and a list of selected items) and wrote a [modified] xml.

I don't see when you could pass a query to [the already running instance of] inkscape.

Unless your extension calls another [hidden] instance of inkscape which would be quite complicated imho

I'd be glad to hear more about interacting with inkscape from an extension.

hulf2012
Posts: 716
Joined: Sat Nov 24, 2012 12:37 pm

Re: Shortcuts in inkscape extensions

Postby hulf2012 » Sat May 30, 2015 2:53 am

v1nce wrote:I don't get it.
As Xav said the extension is called with the path of an xml file (and a list of selected items) and wrote a [modified] xml.

I don't see when you could pass a query to [the already running instance of] inkscape.

Unless your extension calls another [hidden] instance of inkscape which would be quite complicated imho

I'd be glad to hear more about interacting with inkscape from an extension.


That is the idea... I think

See this link... the comments at the end also have information
http://www.janthor.com/sketches/index.p ... scape.html

Greetings
If you have problems:
1.- Post a sample (or samples) of your file please.
2.- Please check here:
http://tavmjong.free.fr/INKSCAPE/MANUAL/html/index.html
3.- If you manage to solve your problem, please post here your solution.

Nathan1123
Posts: 6
Joined: Wed May 20, 2015 3:16 am

Re: Shortcuts in inkscape extensions

Postby Nathan1123 » Sat May 30, 2015 5:37 am

Looks really promising! However, when I call the --query-all command, the resulting coordinates are very different from the actual object locations. Why are they different? and is there some way I can compensate for that?

For example, one of the entries in --query-all comes out as:
text399, 30762.015, 12013.469

However, the actual coordinates of text399 is 30949.857, 12123.882

Nathan1123
Posts: 6
Joined: Wed May 20, 2015 3:16 am

Re: Shortcuts in inkscape extensions

Postby Nathan1123 » Sat May 30, 2015 8:10 am

Well, it's working now. Guess the translated locations are proportionally the same.

Thanks so much!


Return to “Help with using Inkscape”