How to find the inkscape.exe

Discussion about writing code for Inkscape.
iconberg
Posts: 36
Joined: Wed Feb 04, 2015 7:46 pm

How to find the inkscape.exe

Postby iconberg » Wed Feb 11, 2015 4:50 am

Hi,

if i want to call a new instance of inkscape,
how the best way to find the place of the executable?

If there is no better solution i can only try to determine program path and search for it.
Thought inkex contain a function for such a purpose but cant find something.

greetzs

Janne
Posts: 228
Joined: Wed Oct 29, 2014 4:15 am

Re: How to find the inkscape.exe

Postby Janne » Wed Feb 11, 2015 7:14 am

Program Files ( x86) - Inkscape ( the icon ) on Windows 8.1 :)

Janne
Posts: 228
Joined: Wed Oct 29, 2014 4:15 am

Re: How to find the inkscape.exe

Postby Janne » Wed Feb 11, 2015 8:28 am

Off topic: Which file extensions are allowed to be attached here?
Red error message on .png - .svg - .jpg - haven't tried .zip :)

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

Re: How to find the inkscape.exe

Postby hulf2012 » Wed Feb 11, 2015 9:40 am

Hello
If you want to use for extensions, I think this could help:
http://stackoverflow.com/questions/1427 ... ing-python
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.

iconberg
Posts: 36
Joined: Wed Feb 04, 2015 7:46 pm

Re: How to find the inkscape.exe

Postby iconberg » Wed Feb 11, 2015 5:40 pm

Yes, i want to call a new instance from an extension. (I guess i should make my questions more clear :D)
Ok, but i imagine some problems if i search trough directories for the programfile.

It can be installed outside the normal programm directory so i have to scan the whole disk!
And if the user have 2 versions installed, how to choose the right one my extension called from?

Guess i it maybe run in an error for the 2nd situation.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: How to find the inkscape.exe

Postby ragstian » Wed Feb 11, 2015 9:56 pm

Hi.
iconberg wrote:It can be installed outside the normal programm directory so i have to scan the whole disk!

No need to scan the whole disk.
Several ways to get the current working directory in python, simplest is; os.getcwd()

You can also access the system path variable, turning it into a list with split on ";" and search the resulting list for "inkscape".
See the os path spec in python.

RGDS
Ragnar
Last edited by ragstian on Wed Feb 11, 2015 11:13 pm, edited 1 time in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

iconberg
Posts: 36
Joined: Wed Feb 04, 2015 7:46 pm

Re: How to find the inkscape.exe

Postby iconberg » Wed Feb 11, 2015 10:05 pm

ragstian wrote:No need to scan the whole disk.
Several ways to get the current working directory in python, simplest is; os.getcwd()


But is the python included for linux and mac too, thought linux inkscape comes not with an included python!
For win i could use this and step up to get the inkscape.exe, right.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: How to find the inkscape.exe

Postby ragstian » Wed Feb 11, 2015 11:18 pm

Hi.

iconberg wrote:But is the python included for linux and mac too, thought linux inkscape comes not with an included python!


From your subject line it can be deducted that you asked specifically about windows as linux and ios does not use *.exe files.

The working directory should still "point to" the directory where the script resides and not the directory where python resides, (this has to be verified).
One thing to bear in mind is that extensions can be installed in either the inkscape executable path or the user directory path.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: How to find the inkscape.exe

Postby ~suv » Thu Feb 12, 2015 2:06 am

Does the extension 'Extensions > Arrange > Restack' work for you on Windows?

If yes (I presume it does), check its code, and use that as an example how to implement (cross-platform) support to launch the inkscape executable on the command line from within an extension script.

iconberg
Posts: 36
Joined: Wed Feb 04, 2015 7:46 pm

Re: How to find the inkscape.exe

Postby iconberg » Thu Feb 12, 2015 4:18 am

Didnt expected that it works but it does :)
I guess the pyhton process gets the enviroment from the parent.
Thanks.


Return to “Programming”