Get Maya Version And Bin Location

Sometimes it is important to deduce the version and bin location of the Maya your are working with. Getting the version number is easy:


should be sufficient. But there seems no built-in MEL command to get where the Maya application is installed. I tried to write a procedural to do that trick:

proc string getApplicationLocation()
string $scpt =
"import sys, os\n\
def where_maya_app_resides(path):\n\
    appName = '/Maya'\n\
    if sys.platform == 'win32':\n\
        appName = '/Maya.exe'\n\
    for apath in path:\n\
        if os.path.exists(apath+appName):\n\
            return apath\n\
    return 'maya not found in any path'\n";

        return python("where_maya_app_resides(sys.path)");

Actually, it is done in Python. Calling sys.path in Maya Python will returns a number of module search directories. Usually the first one will be Maya/bin. To make sure it returns the bin directory, I check every directory to find whether Maya(.exe) does exist inside it. On Mac, it returns: /Applications/Autodesk/maya2008/


1 Comment

Filed under MEL, Python

One response to “Get Maya Version And Bin Location

  1. Check out sys.executable, if you want to cut down on a few lines of code 😉

    import os
    import sys
    maya = os.path.join(os.path.split(sys.executable)[0], ‘maya.exe’)
    print maya
    C:\Program Files\Autodesk\Maya2010\bin\maya.exe

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s