Writing your own .NET plug-in

The Maya .NET SDK is available in 64-bit only. Ensure that your Maya .NET plug-in projects are also compiled in x64.

The plug-in must implement the Autodesk.Maya.OpenMaya.IExtensionPlugin interface. It can be a default implementation that does nothing.

The SDK searches for the first class implementing this interface, but to accelerate the discovery of the IExtensionPlugin implementation, .NET plug-ins may optionally contain a single ExtensionPlugin assembly attribute, as so:

[assembly: ExtensionPlugin(typeof(MayaNetPlugin.helloWorldPlugin), "Autodesk", "1.0", "Any")]

For more information regarding assembly attributes, see Using .Net assembly attributes.

This assembly attribute can appear in any source file of your library outside of the namespace, usually after the using declarations.

A plug-in library can contain any number of custom .NET commands, or .NET nodes.

The documentation for the Maya .NET SDK methods support Intellisense, and pops up as you type your code.

NOTE:
  • When creating your custom .NET plug-in project, you must set the Copy Local property of the Maya assembly references to false.

    When the Copy Local property is enabled (default), Visual Studio copies the references that are required to run your code to the \bin output folder of your .NET project, and will load them each time. However, because your plug-in will run in Maya, the references are already available with the Maya install and loaded.

    Your plug-in may fail to initialize as a result.

    To set Copy Local to false, right-click your reference in the Solution Explorer in Visual Studio. Select Properties, then set ‘Copy Local’ to false in the Properties window that appears.

  • If your plug-in references assemblies that are not in the Maya bin folder, you must add the path of these assemblies to the PATH environment variable in order for Maya to load your plug-in.

Comparing object instances

Comparing two object references using == or != may not work as expected in all cases. For example, an object deriving from a .NET base class might be moved to a new memory instance. To compare Maya objects, use the member functions MObject.equalEqual and MObject.notEqual instead.

About internal SWIG types

Some types exposed in the API have the substring swig in their name. These are for internal use only and are not supported.

Creating a dockable WPF control

The MDockStation class provides facilities for docking a WPF control in the windows control. See the DAGExplorer example under the devkit\dotnet\wpfexamples folder of your Developer Kit installation.