Hi there...

sys.argv[0] returns the first argument of the command line executed to
run the current application. When inside maya, it will return the
command line executed to run maya itself, therefore the result you're
getting.

What you can do is to get what you want is: in the same folder where
you plugin is, create another file named something like
"pluginLocation.py" or something like that.

fill it with something simple, like just "impor os"

after you load your plugin in maya, go to the script editor and type:

import pluginLocation
import os
currentDir = os.path.dirname(pluginLocation.__file__)
print currentDir

this will give you the folder where your plugin is.

when you load a plugin in maya, maya allways adds the plugin path to
the python search path, so if the plugin has some sub-modules in the
same folder (like our pluginLocation.py) it can just import then
normally. And all modules have the __file__ var that stores its path.

Let me know if it works...

have fun...

-H

On Dec 24, 5:55 pm, debug <[email protected]> wrote:
> Hi-
> I'm currently trying to work out the current location of the current
> running python plugin to get the path of a normal python I always use:
>
> currentDir = sys.argv[0]
> print (currentDir)
>
> However when I use it from a running python plugin I get the result:
>
> /Applications/Autodesk/maya2009/Maya.app/Contents/MacOS/Maya
>
> Which isn't the right path obviously.
>
> Any ideas whats going on?
>
> Many thanks in advance
>
> Dom
--~--~---------~--~----~------------~-------~--~----~
Yours,
Maya-Python Club Team.
-~----------~----~----~----~------~----~------~--~---

Reply via email to