Maya Python Plug-in Learning Path

Welcome!

This Learning Path aims to outline the important concepts, classes, and functions used to develop Maya plug-ins with Python. We recommend reading the topics in this Learning Path in sequential order, however the annotated code samples can be consulted independently as reference material.

NOTE:This learning path uses both the Maya Python 1.0 and 2.0 APIs. The 2.0 API is faster and more "Pythonic", though not all features from 1.0 are available yet in 2.0. For details on the differences between this API and the legacy 1.0 API, see Maya Python API 2.0.

"Now with 100% more voxels!"

Python Scripts and Python Plug-ins - What's the Difference?

To begin, an important distinction should be made here between Python scripts and plug-ins for Maya:

  • Python scripts - These programs can be executed in Maya's interactive Script Editor window. Python scripts generally make extensive use of the maya.cmds module, whose functionality emulates the majority of Maya's MEL commands. The import statement below is typically found at the head of Maya Python scripts.
    import maya.cmds as cmds
    In this learning path, we will use the maya.cmds module to execute our Python plug-ins.
    NOTE:For more information on the maya.cmds Python module, consult Maya User Guide > Technical Documentation > CommandsPython.
  • Python plug-ins - These programs are loaded by Maya's Plug-in Manager from C:\Users\<username>\Documents\maya\<version>\plug-ins, and from the directories defined in the MAYA_PLUG_IN_PATH environment variable. Maya Python plug-ins can be used to define your own commands, nodes, shaders, constraints, file translators, and deformers to name but a few customizable elements. Python plug-ins for Maya make use of several OpenMaya modules, which are based on Maya's C++ API.

    2.0:

    import maya.api.OpenMaya       as OpenMaya        # Common classes
    import maya.api.OpenMayaAnim   as OpenMayaAnim    # Animation classes
    import maya.api.OpenMayaRender as OpenMayaRender  # Rendering classes
    import maya.api.OpenMayaUI     as OpenMayaUI      # User interface classes
    

    1.0:

    import maya.OpenMaya       as OpenMaya        # Common classes
    import maya.OpenMayaMPx    as OpenMayaMPx     # Classes from which to inherit
    import maya.OpenMayaAnim   as OpenMayaAnim    # Animation classes
    import maya.OpenMayaFX     as OpenMayaFX      # Effect classes (hair, particles, fluids)
    import maya.OpenMayaRender as OpenMayaRender  # Rendering classes
    import maya.OpenMayaUI     as OpenMayaUI      # User interface classes
    import maya.OpenMayaCloth  as OpenMayaCloth   # Cloth classes