Maya - Plug-in API

The Maxwell Maya plug-in offers an API which can be used by developers to customize the export process. Any shape node can be marked as a custom object, in which case the Maxwell exporter does not attempt to process the node itself; instead, it calls a piece of MEL or Python code specified by the developer and that code can create the needed object or objects in the Maxwell scene. It is also possible to register callbacks which are invoked at various stages in the export process, to perform scene-wide modifications which are not necessarily linked to a single shape node.

The API is available for C++ and Python. The Python version is easiest to use, since you can just call the API directly in your export or callback functions. However, there are cases when you need to use C++, e.g. when you don't want to distribute the source code for your custom exporter, or when you have to call other C++ libraries. In this case, you will have to add your own plug-in MEL command using the Maya API (based on MPxCommand) and use that command in your custom export code. You command will then load and call the C++ Maxwell API. In this case, MEL acts as a glue layer between the Maxwell plug-in and your plug-in, as this is the simplest way in which one Maya plug-in can invoke code from another Maya plug-in.

To mark a shape node as custom, add a string attribute called maxwellCustomExportMEL or maxwellCustomExportPy and set it to the MEL or Python code you wish to run. The Maxwell plug-in will append the full path to the object being exported to the MEL string before executing it, in case you want to process the node in some way using MEL before passing control to your plug-in command. The Python code is executed as-is, since the API provides a straightforward way of obtaining a handle to the current object.

In some cases it is useful to process an object after all the other objects in the scene have been exported. For example, if your node creates instances of other shapes, it will have to be exported after those shapes have been exported. To support this scenario, the Maxwell plug-in splits the export into two phases. By default, all the objects are exported in the first phase. However, if a shape has an integer attribute called maxwellCustomExportPhase and its value is above 0, the shape will be processed in a second phase, after all the phase 0 objects. The order in which objects are considered inside each phase is unspecified, so it is not possible to represent more complex dependency chains, such as creating instances of objects processed in the second phase.

Developer Guide

  1. Loading the C++ API
  2. Managing objects returned by the C++ API
  3. Callbacks
  4. Using the Python API
  5. Exporter states and callbacks in detail
  6. Samples

Class Reference