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

By Christopher Diggins - 29 Sep, 2011

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:

 

Published In
Tags
9 Comments
To post a comment please login or register
GeneralCody | 5 years ago
Is the .Net Max SDK a priority for Autodesk these days? I surely hope so, as I'm a C# developer... I have just purchased Max 2013 and I can see that the .dll's are present meaning that this is something they plan on supporting for future versions, but is it a priority?
Edited by GeneralCody 5 years ago
CountZr0 | 5 years ago
When I run this line: Interface13.PushPrompt "Pinch me, I'm dreaming!" I get 'undefined' in MAXScript Listener after the first 6 lines seem to work and produce this: dotNetClass:System.Reflection.Assembly "C:\Program Files\Autodesk\3ds Max 2012\" dotNetObject:System.Reflection.RuntimeAssembly dotNetClass:Autodesk.Max.GlobalInterface dotNetObject:Autodesk.Max.Global dotNetObject:Autodesk.Max.Wrappers.Interface13 Unfortunately, I am a super-noob in Max and .NET (though I've some experience in Maya/MoBu python IDEs), so there are so many new elements, it is hard to know what I've missed. -jason
christopher-diggins | 6 years ago
>> 1) What does this get me that MaxScript and the current .Net exposure doesn't? These are two separate things. 1) Not everything is exposed to MAXScript. For example the reference system, IGame, Biped, Nitrous, some Viewport functionality, low-level Mesh manipulation and so-on. 2) .NET exposure previously of the SDK was virtually non-existant. Another answer to your question is the simple fact that you can virtually anythign you did in MAXScript now using C#. That alone is a pretty big win in my opinion (C# tools, C# libraries, etc.). With a bit of work you can even get IronPython working. >> 2) Is there a difference in performance for a function that, for example, gets properties from a large set of objects when implemented through the .Net interface to the SDK than when done through vanilla MaxScript? I haven't done any performance measurements. >> 3) When can we see more examples, especially o f functionality that we don't already have in MaxScript? I've never used the SDK, so any new examples would be really appreciated. I can't say when, but I will make sure that people in our organization take note.
JHaywood | 6 years ago
This is really exciting, but I have a few questions... 1) What does this get me that MaxScript and the current .Net exposure doesn't? 2) Is there a difference in performance for a function that, for example, gets properties from a large set of objects when implemented through the .Net interface to the SDK than when done through vanilla MaxScript? 3) When can we see more examples, especially of functionality that we don't already have in MaxScript? I've never used the SDK, so any new examples would be really appreciated.
christopher-diggins | 6 years ago
>> Why dont you make Video? What would you like to see in a video? Do you have examples of instructional programming videos that you have found useful? Do you really find it faster to learn from videos than reference material? >> Does this new DLL allow us to open files like WFT (GTA4+) and DFF (GTA3+) models? No. >> And do we finally have advantage over ZBRUSH I can't answer that question.
3dgamer | 6 years ago
Thanks for all this. But you should know that game modelers and programmers have no time to read documentation. Why dont you make Video? Does this new DLL allow us to open files like WFT (GTA4+) and DFF (GTA3+) models? Max users who are in game programming are forced to use zmodeler and blender to open such files. And do we finally have advantage over ZBRUSH?
jfyelle | 6 years ago
mr spacefrog, >> That looks like a bit of a party crasher to me... The real party is when it becomes available in a full release. Meanwhile, you can still give it a proper test drive and/or do internal tools for you or your group.
christopher-diggins | 6 years ago
>> Great stuff... Thank you! >> * Scripts using that new .NET exposes, will only run on machines having the advantage pack installed... right ? Right. >> we are not allowed to pack and distribute the assembly DLL with our scripts, to be able to run the scripts on other machines Right. They will have to install the subscription advantage pack. >> That looks like a bit of a party crasher to me... I don't see how it different than any other major new update to the SDK or MAXScript.
spacefrog | 6 years ago
Great stuff... Quick questions : * Scripts using that new .NET exposes, will only run on machines having the advantage pack installed... right ? * we are not allowed to pack and distribute the assembly DLL with our scripts, to be able to run the scripts on other machines. That looks like a bit of a party crasher to me...