Mac OS X environment

The Maya Developer Kit is available from the Autodesk Developer Network. After you copy the 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 /Applications/Autodesk/maya2018. You should therefore have the following folder structure:

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

NOTE:

All plug-ins that are compiled for the Mac OS X platform must export the MApiVersion string; otherwise a linker error will occur. Exporting the MApiVersion string can be done by including <maya/MApiVersion.h>. Most plug-ins already include <maya/MFnPlugin.h> which in turn includes <maya/MApiVersion.h>; therefore, in most cases, no action needs to be taken.

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: ../Maya.app/Contents/MacOS

Compiler requirement

To compile plug-ins and standalone applications on Mac OS X, you must have the following installed: El Capitan 10.11.6 , Xcode 7.3.1 with SDK 10.11, clang with libc++.

NOTE:

Maya does not provide binary compatibility for plug-ins between releases. For example a plug-in built in Maya 2015 will not load in Maya 2016. With each new release, the source must be recompiled. However, it is our goal to maintain source-code compatibility, and in the majority of cases, no changes to the source will be required.

Maya Plug-ins

There are two ways of building plug-ins on Mac OS X. You can either use Xcode or the Makefile that we supply with the Developer Kit.

Building with Makefiles

  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=/Applications/Autodesk/maya2018/Maya.app/Contents
    

    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 /Applications/Autodesk/maya2018/Maya.app/Contents
    

    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 working directory and copy the plug-in sources into it. 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 /Applications/Autodesk/maya2018/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 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 */*.bundle 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.

Building with Xcode project files

To build one of the example plug-ins using Xcode, you must use the same version of Mac OS X that you'll be running Maya on and have the Xcode application installed. Then, do the following:

  1. Browse to /Applications/Autodesk/maya2018/devkit/plug-ins.
  2. Make a copy of the subdirectory containing the plug-in you wish to build. For example, if you wish to build the circleNode plug-in then make a copy of /Applications/Autodesk/maya2018/devkit/plug-ins/circleNode
  3. Browse into the copy of the directory and double-click on the plug-in's Xcode project file, e.g. circleNode.xcodeproj
  4. Select the Build option from the Build menu. The resulting plug-in will have an extension of .bundle and will be located in the build subdirectory, under the configuration you used for the build. For example, if your circleNode plug-in is located in $HOME/myCircleNode and then built using the Debug configuration, then the plug-in will be in $HOME/myCircleNode/build/Debug/circleNode.bundle.
NOTE:In XCode 4.0 and above, compiled plug-ins are located in a hidden directory instead of in the /build folder where the project files are located. As a result, you may be unable to locate the plug-in and load it in Maya. You can change the build location user preference to Legacy, so that the plug-in is compiled to the location of the project files and under the /build directory as described above. To change the build location preference, open the Locations Preferences pane and find the Derived Data settings, then select Advanced and then select Legacy.

In order for Maya to find the plug-in you must set a number of environment variables to point to the directories containing its files. See Installing a Maya plug-in for more information regarding installing the plug-in and setting environment variables in the Maya.env file. As an example, in this case, if you want to access the circleNode and whatisCmd Developer Kit plug-ins from within Maya, then your Maya.env file should contain the following:

MAYA_PLUG_IN_PATH = $HOME/myCircleNode/build/Debug
MAYA_SCRIPT_PATH = $HOME/myCircleNode
XBMLANGPATH = $HOME/myCircleNode/%B

Maya API applications

Building API applications

For building API applications, we only provide a Makefile solution. To build the supplied stand-alone application examples, you need to do the following:

  1. Define the MAYA_LOCATION. See Step 1 in Maya Plug-ins above for more information.
  2. Create a local application directory and copy the Developer Kit resources to your local directory.
    mkdir –p $HOME/devkit/applications    
    cd $HOME/devkit/applications
    cp –r /Applications/Autodesk/maya2018/devkit/applications/* .
    
  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 applications:
    make clean
    make
    

The shell script mayald is used to link Maya API applications. It is important that the MAYA_LOCATION be set to the correct version of Maya before running the command, otherwise the application may fail to execute properly.

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.

Running API applications

On Mac OS X, you must set the DYLD_LIBRARY_PATH environment variable before you try to execute one of these applications so the runtime linker can find the Maya shared libraries.

The recommended procedure for preparing to build and run stand-alone applications is to set the following environment variables:

export MAYA_LOCATION=/Applications/Autodesk/maya2018/Maya.app/Contents
export DYLD_LIBRARY_PATH=$MAYA_LOCATION/MacOS
export DYLD_FRAMEWORK_PATH=$MAYA_LOCATION/Frameworks