For those of you who are already on the Maya Feedback Community forum (beta forum), it is probably not really new. But for all others, this is quite a big change - Maya will get a native .NET API for its Windows platform version.
So I am proud to announce the Maya .NET API here.
The Maya .NET API is a new technology that
allows Maya plug-in developers to harness the full power of Microsoft’s .NET
Framework. With the Maya .NET API, developers extending Maya are now able
to:
- Access the Maya API in a friendly, idiomatic style that is familiar to .NET developers
- Develop code faster and explore the SDK with Intellisense for Microsoft Visual Studio IDE
- Leverage their development skillsets by using their favorite .NET language, such as C#, VB
- Unleash the rich set of .NET Framework services when building Maya plug-ins, including Remoting, Language Integrated Query, Serialization, and advanced Web services
- Integrate WPF/XAML user interfaces into their plugins by docking them into Maya’s Qt-based panels
You can download the Maya .NET API BETA from the Maya Community Feedback homepage in the Downloads section. Please carefully read the included User’s Guide for limitations, important notes, and tips. Defects and comments can be logged with the Report Problem button in Maya Feedback Community. Also, you are invited to post actively in the .NET API User Forum, where Autodesk developers will be able to interact with you.
It is for Windows only and the .Net API is a thin C++/CLI layer around the MPx classes, whereas other classes where generated using SWIG and P/Invoke. That means that it does not support Mono and therefore do not support Linux and OSX.
The API will not be backward compatible while in theory it could be back-ported to previous releases (see my post from May 28th).
On the last beta version, we added many new things, and some were based on the feedback we received from Studios working with us on developing/finalizing that API.
- The Maya’s plug-in manager now natively recognizes .NET plug-ins. .NET plug-ins now behave exactly like C++ plug-ins (except they must be named with a ".nll.dll" extension). That includes them being listed in the plug-in manager window, being able to load/unload them, using the same MEL commands to manage them as C++ plug-ins, and support for Maya Modules and MAYA_PLUG_IN_PATH.
- Lots and lots of examples. See devkit\dotnet for a collection of many plugin examples ported to C#
- Nifty WPF C# example. See devkit\dotnet\wpfexamples for a plugin shows off dynamic code compilation, LINQ queries over the Maya scene graph, a grid control, WPF user interface that docks with Qt, a 3D viewer in C#, and more!
- Scene message callbacks are modeled as .NET events, and are even listed in Intellisense in Visual Studio
- Visual Studio project template for generating boilerplate plug-in code. See the User’s Guide for the embedded ZIP file.
What is really new and cool when using that API, is that you really feel developing on .Net vs. using the old Maya API approach. For example, you do not really need an entrypoint like in C++ or Python or even the creator() or initialize() function. Nor you need to register anything yourself by code. Instead you decorate your classes with attribute(s). Let me give you a simple "Hello World" sample and this is a very simple example.
This is the Python code :(
import sys import maya.OpenMaya as OpenMaya import maya.OpenMayaMPx as OpenMayaMPx # command class HelloWorldCmd(OpenMayaMPx.MPxCommand): kPluginCmdName = "spHelloWorld" def __init__(self): OpenMayaMPx.MPxCommand.__init__(self) @staticmethod def cmdCreator(): return OpenMayaMPx.asMPxPtr( HelloWorldCmd() ) def doIt(self,argList): print "Hello World!" # Initialize the script plug-in def initializePlugin(plugin): pluginFn = OpenMayaMPx.MFnPlugin(plugin) try: pluginFn.registerCommand( HelloWorldCmd.kPluginCmdName, HelloWorldCmd.cmdCreator ) except: sys.stderr.write( "Failed to register command: %s\n" % HelloWorldCmd.kPluginCmdName ) raise # Uninitialize the script plug-in def uninitializePlugin(plugin): pluginFn = OpenMayaMPx.MFnPlugin(plugin) try: pluginFn.deregisterCommand(HelloWorldCmd.kPluginCmdName) except: sys.stderr.write( "Failed to unregister command: %s\n" % HelloWorldCmd.kPluginCmdName ) raise
And the Maya .Net equivalent
using System; using Autodesk.Maya.Runtime; using Autodesk.Maya.OpenMaya; using Autodesk.Maya.OpenMayaMPx; [assembly: MPxCommandClass(typeof(MayaNetPlugin.helloWorldCmd), "helloWorldCmd")] namespace MayaNetPlugin { public class helloWorldCmd : MPxCommand, IMPxCommand { public override MStatus doIt(MArgList argl) { MGlobal.displayInfo("Hello World\n"); return MStatus.kSuccess; } } }
Nothing more, nothing less needed - Really!
And just to give you an idea on how simple it is - here is an abstract on how you could initialize node's attributes in .Net.
[assembly: MPxNodeClass(typeof(MayaNetPlugin.myNode), "myCSharpNode", 0x00000000)] class myNode : MPxNode, IMPxNode { [MPxNodeNumeric("in", "input", MFnNumericData.Type.kFloat, Storable = true)] public static MObject input = null; [MPxNodeNumeric("out", "output", MFnNumericData.Type.kFloat, Storable = false, Writable = false)] [MPxNodeAffectedBy("input")] public static MObject output = null; override public MStatus compute(MPlug plug, MDataBlock dataBlock) { ... } }
Excepted the code required in compute() this is it for your class node implementation.
If you interested helping us, please join on the beta forum or drop me a line!
where to download the .NET feature,
what is "Maya Community Feedback homepage"?
Posted by: harry | December 04, 2012 at 01:12 PM
Hi Harry,
yes correct http://beta.autodesk.com and ask to be on the Maya program. If you got any problem to join, let me know and I'll get you on.
cyrille-
Posted by: Cyrille Fauvel | December 04, 2012 at 11:48 PM
I've sent a request two days ago on the Community Feedback, but i can't access to the download page or anything else. I really want to try this new feature :)
Posted by: Maïckel Pasta | December 05, 2012 at 02:54 PM
Hi Maickel
can you drop me an email with your Community Feedback account, I'll get you on
Posted by: Cyrille Fauvel | December 06, 2012 at 01:43 AM