Linux environment

Maya plug-ins

The Maya Developer Kit is available online at Autodesk Exchange at https://apps.exchange.autodesk.com/MAYA/en/Home/Index. After you copy your archive to your $Home directory and unarchive it, a folder called devkitBase is created. There are a number of example plug-ins located in devkitBase/devkit/plug-ins. The Developer Kit also contains several Maya API applications, located in devkitBase/devkit/applications. Copy the /devkit and /mkspecs folders into /usr/autodesk/maya2018.

Your should therefore have the following folder structure:

  • /usr/autodesk/maya2018/devkit
  • /usr/autodesk/maya2018/include
  • /usr/autodesk/maya2018/mkspecs
  • /usr/autodesk/maya2018/bin
NOTE:

To compile your custom plug-ins, you can also find the C++ API header files and libraries in the following folders of your Maya installation:

  • Header files: ../include/maya
  • Libraries: ../lib

Before you can use these plug-ins, you need to build them.

  1. Define the MAYA_LOCATION environment variable to point to the directory where Maya is installed. If your command-line shell is sh, bash or ksh then the commands would be as follows:

    export MAYA_LOCATION=/usr/autodesk/maya2018
    

    If you don't want to have to reset MAYA_LOCATION each time you log in, then add those commands to your $HOME/.profile as well.

    If your command-line shell is csh or tcsh then command would be:

    setenv MAYA_LOCATION /usr/autodesk/maya2018
    

    and you can also add it to your $HOME/.cshrc to avoid having to reset it each time you log in.

  2. Create a local plug-in directory ($HOME/devkit/plug-ins) and copy the Developer Kit resources to your local directory. This step is necessary because you likely won't have write permissions on the directories where Maya's Developer Kit is installed.

    mkdir -p $HOME/devkit/plug-ins
    cd $HOME/devkit/plug-ins
    cp -r $MAYA_LOCATION/devkit/plug-ins/* .
    
  3. Set the DEVKIT_LOCATION environment variable to the folder at which you have unarchived your devkit package, that is, where the /include and /mkspecs directories are located.
  4. Now you're ready to build the plug-ins:
    make clean
    make
    
  5. You can now install and load your Developer Kit plug-ins. In your local plug-in directory, create 3 folders: plug-ins, scripts, icons.
    mkdir plug-ins scripts icons
  6. Copy plug-in files into the plug-ins directory, scripts file into the scripts directory, icon files into the icons directory.
    cp */*.so plug-ins
    cp */*.{mel,py} scripts
    cp */*.{png,xpm,cur,rgb} icons
  7. Create a Maya.env file with three environment variables to specify to Maya where to search for plug-ins, scripts and icons. The three environment variables are:
    • MAYA_PLUG_IN_PATH - directories to search for plug-ins
    • MAYA_SCRIPT_PATH - directories to search for MEL and Python scripts
    • XBMLANGPATH - directories to search for icons

    For more information about the Maya.env file, including the location to which it should be saved on each platform, see Setting environment variables using Maya.env. Using Maya.env makes it easy to set up the same runtime environment on another system by simply copying the file. You can still set explicit values for these variables on the command line and they are prepended to the values given in Maya.env.

    Set your Maya.env file to use the common directories:

    MAYA_PLUG_IN_PATH = $HOME/devkit/plug-ins/plug-ins
    MAYA_SCRIPT_PATH = $HOME/devkit/plug-ins/scripts
    XBMLANGPATH = $HOME/devkit/plug-ins/icons/%B
    

    Now when you start up Maya and bring up the Plug-in Manager you'll see all of the Developer Kit plug-ins, listed within a common section.

NOTE:The instructions above describes how to access all of the Developer Kit plug-ins from within Maya. If you want to access only one specific plug-in, for example, the circleNode and whatisCmd C++ plug-ins, then your Maya.env file should contain the following:
MAYA_PLUG_IN_PATH = $HOME/devkit/plug-ins/circleNode:$HOME/devkit/plug-ins/whatisCmd
MAYA_SCRIPT_PATH = $HOME/devkit/plug-ins/circleNode:$HOME/devkit/plug-ins/whatisCmd
XBMLANGPATH = $HOME/devkit/plug-ins/circleNode/%B:$HOME/devkit/plug-ins/whatisCmd/%B

If you now start Maya and open the Plug-in Manager window, you should see the circleNode and whatisCmd plug-ins each listed within its own section.

Maya API applications

Building API applications

To build the supplied stand-alone application examples, you need to do the following:

  1. Define the MAYA_LOCATION. See Step 1 above for more information. MAYA_LOCATION must be set to the correct version of Maya before running the mayald command below.
  2. Create a local plug-in directory ($HOME/devkit/plug-ins) and copy the Developer Kit resources to your local directory.

    mkdir -p $HOME/devkit/applications
    cd $HOME/devkit/applications
    cp -r $MAYA_LOCATION/devkit/applications/* .
    make clean
    make
    

Use the shell script mayald to link Maya API applications. When linking your own plug-ins, make sure to provide the mayald command with a list all of the OpenMaya libraries containing the API classes you have used. The reference pages for each class specify the particular OpenMaya library containing the class.

NOTE:It is possible to build a standalone application that does not have the ability to read in some Maya models. Specifically, if you try to read a file with IK using the Developer Kit "readAndWrite" app, you get an error about a failed connection and the ik fails in the scene. To counter this, you must force the IK subsystem to load before the file is loaded. After the MLibrary() call is made, add in some command that uses the IK subsystem before the call to MFileIO::open(). The following command works:

MGlobal::executeCommand( "ikSystemInfo -q qsh" );

Running API applications

As long as MAYA_LOCATION is still defined, compiled applications can be run in the directory they were generated in. For example, follow these steps to run the surfaceTwist application:

cd $HOME/devkit/applications
./surfaceTwist