![]()
Introduction
Autodesk® Maya® is an open product. This means that anyone outside of Autodesk can change Maya’s existing features or add entirely new features. There are two ways you can modify Maya:
- MEL™—(Maya Embedded Language) is a powerful and easy to learn scripting language. Most common operations can be done using MEL.
- Python™—is a powerful and easy to learn scripting language, which provides an interface to the Maya commands.
- API—(Application Programmer Interface) provides better performance than MEL. You can add new objects to Maya using the API, and code executes approximately ten times faster than when you perform the same task using MEL. Also, you are able to execute MEL commands from the API.
- Maya Python API—Based on the API and allows the API to be used through the Python scripting language.
Please see the “MEL and Expressions” book for an introduction to MEL and the “Python” book for its equivalent interface. This book provides a technical introduction to the Maya API and the Maya Python API.
Overview
The Maya API is a C++ API that provides internal access to Maya and is available on the following platforms: Microsoft® Windows®, Linux®, and Apple® Mac OS® X. You can use the API to implement two types of code resources: plug-ins which extend the functionality of Maya, or stand-alones such as console applications which can access and manipulate a Maya model.
Plug-ins can be built in two ways:
- As dynamic or relocatable libraries which are loaded into Maya using standard operating system functionality. Plug-ins work by accessing the symbol space of the host application Maya. Access to the symbol space of other loaded plug-ins is not available.
- As scripts that use the Maya Python API. Referred to as a scripted plug-in (“sp”).
When you use dynamic libraries, the operating system that you develop on place various restrictions on how to build and name plug-ins. The file extensions for plug-ins are:
- Linux:
.so
- Windows:
.mll
- Mac OS X:
.bundle
- All platforms for scripted plug-ins:
.py
Also, the rules for creating plug-ins and API applications differ on the various platforms. These rules are described in more detail later in this book.
The Developer Kit
The Maya API is located in the developer’s kit in the Maya Installation package. On some platforms, the Maya installer does not install the developer kit by default. As a result, you may have to specify that you want to install the devkit during the installation process. The developer kit contains 3 major components: include files, libraries, and examples.
Include Files
We provide the header files which interface with Maya. The header files that come with the developer kit are located in the
include/maya
directory. Maya header files normally start with theM
prefix. The letters following the M indicates header file type:Fn
for function set,It
for iterator,Px
for proxy class. These naming conventions will be described in more detail later.Libraries
The API is packaged as a set of libraries that correspond to the different functional areas of Maya. These libraries are:
OpenMaya—Contains fundamental classes for defining nodes and commands and for assembling them into a plug-in.
OpenMayaUI—Contains classes necessary for creating new user interface elements such as manipulators, contexts, and locators.
OpenMayaAnim—Contains classes for animation, including deformers and inverse kinematics.
OpenMayaFX—Contains classes for Autodesk® Dynamics™.
OpenMayaRender—Contains classes for performing rendering functions.
These libraries are shared libraries so that many plug-ins can use them at the same time. The libraries are located in the
lib
directory.Examples
The Maya API examples are located within the
devkit
directory. This directory contains anapplications
andplug-ins
folder. Theapplications
folder contains examples of stand-alone API applications while theplug-ins
folder contains Maya API plug-in examples. The method for building stand-alone or plug-ins varies on the different platforms. In most cases,Makefiles
are used. On Windows and Mac OS X, we have provided IDE solutions for building most of our examples.Maya Python API examples are located within the
plug-ins/scripted
folder of the Maya Development Kit.
We do not provide the compiled plug-in and applications binaries on the Maya installation DVD. You must build these yourself. Building the devkit examples is described in more detail in the “Setting up your plug-in build environment” section.
Documentation
We provide extensive documentation with the Maya API. The documentation components we provide are:
- This technical introduction to the Maya API
- The API class descriptions
This technical introduction to the Maya API includes a section for the Maya Python API. In addition, our class description documentation is used for both C++ and Maya Python API development as it includes information for both of these development approaches.
Related documentation includes:
- The MEL and Expressions guide
- The Maya MEL command reference
- The Maya Nodes and Attributes reference. Working with Maya nodes is a normal part of programming the Maya API
- The What’s New information provided with each release
- The Release Notes that provide items of interest for developers
You can access these resources from the Maya Help (Help > Maya Help).
Other Requirements
Since the Maya API is a C++ API, it is best to have an understanding of the following:
- virtual functions
- class inheritance (including multiple)
- stream classes
- operator methods(there are many operator methods in the Maya API)