.NET SDK Enhancements in the 3ds Max 2012 Subscription Advantage Pack

If you are already a hard-core .NET programmer and have installed the 3ds Max 2012 Subscription Advantage Pack then you might want to quickly open up a new file in the Autodesk root folder named "Autodesk.Max.dll" in your Visual Studio Object Browser.
So what is so special about this little DLL? Previously the 3ds Max .NET SDK offered only a tiny subset of the entire SDK functionality. With this advantage pack we have released a new class library (the Autodesk.Max.dll assembly) that exposes virtually every C++ API element to .NET.

This library can be used from 3ds Max in several ways:
  1. From MAXScript
  2. From managed plug-ins and CUI actions loaded from /bin/assemblies
We have updated the 3ds Max SDK documentation with this release with new information regarding the .NET SDK. Some starting points for information on the .NET library are:
The .NET SDK mimics the structure of the C++ API, so you will also need to consult out the C++ reference documentation. Note that opening the assembly in Visual Studio's object browser is a very quick and easy way to find what you are looking for.
The fastest way to get started using the new enhancements to the .NET SDK is from MAXScript. First load the assembly and get some handles that you can work with (hint: this could be a good start-up script):
-- Load the assembly
AssemblyType = dotNetClass "System.Reflection.Assembly"
maxroot = pathConfig.GetDir #maxroot
AssemblyType.LoadFile (maxroot + "\Autodesk.Max.dll")

-- Get a handle to the global interface instance
GlobalInterfaceType = dotNetClass "Autodesk.Max.GlobalInterface"
global GlobalInterface = GlobalInterfaceType.Instance
global Interface13 = GlobalInterface.COREInterface13
Now let’s actually do something:
Interface13.PushPrompt "Pinch me, I'm dreaming!"
You should now a little message in the prompt window at the bottom of 3ds Max.

So what the heck is happening? The .NET class Autodesk.Max.GlobalInterface provides a means to access the global methods and objects in the 3ds Max SDK. There is one global instance of this interface already instantiated which you can get via the static property: Autodesk.Max.GlobalInterface.Instance.
So the get access global function in the C++ SDK such as GetCOREInterface13()we can find it as a property of Autodesk.Max.GlobalInterface, specifically Autodesk.Max.GlobalInterface.Instance.COREInterface13. It is converted from a function to a property because it has the prefix “Get” and no arguments. This is a bit complicated, but once we store the key interface instances in global variables we can start using them.
Using the global variable Interface13 defined in the above script we can now call any function from the Interface13 class in the C++ SDK (and all of its base classes).
Here is a slightly more interesting MAXScript example that walks the nodes in a scene and calls a function with each one.
function VisitNodes n f = (
  -- Call the function "f" passing the node "n" as an argument
  f n
  -- Recursively Visit all of the children nodes
  for i = 0 to n.NumberOfChildren - 1 do
  VisitNodes (n.GetChildNode i) f

-- Declare a function that we can use to visit each node with
function NodeNamePrinter n = print n.Name

-- Visit the root node and all of its children using the NodeNamePrinter function
VisitNodes Interface13.RootNode NodeNamePrinter
This should keep you 3ds Max hackers busy for a while. I know I have been enjoying playing with it!
For more information on other features of the 3ds Max 2012 Subscription Advantage Pack visit the following blogs on the Area:

Live Stats