C# IGlobal Objects - What are they?


I’m trying to figure out what all the abstract classes defined in IGlobal are all about - I have a fundamental lack of understanding, and I’m hoping someone can straighten me out!

By IGlobal, I’m referring to GlobalInterface.Instance, which returns an IGlobal object. This is a super-useful class - I use it to look up values (e.g. IGlobal.SaveRequiredFlag) and to create instances of Max objects (e.g. IGlobal.FPValue.Create();).

There are also a ton of abstract classes defined in IGlobal that look really interesting. For instance:

public abstract class IGlobalRenderer : MarshalByRefObject
	public abstract void CreateUnmanagedWrapper(Autodesk.Max.Plugins.Renderer pluggableClass);

	public abstract IRenderer Marshal(IntPtr handle);

This seems really useful! I’d like to be able to get access to renderers in Max, and that class returns an IRenderer if I pass it an IntPtr.

However, if you open the Autodesk.Max DLL, you won’t find any reference to IGlobalRenderer. There is one implementation: Autodesk.Max.__Global.__GlobalRenderer. But it’s not actually used anywhere.

So I have no idea how to actually use this class - how would I go about getting an IntPtr to a particular renderer? Why would I have an IRenderer IntPtr without already having an IRenderer reference? What is this class, and all the others in IGlobal, actually used for?


Found a bit more information on this, and wanted to share with anyone else that’s interested:

Here’s an example I got working for IGlobal.IGlobalSceneExport:

var @class = Max.ObjectFactory.CreateClassID(0, 40085);
var ptr = @class.NativePointer;
var export = Max.Global.SceneExport.Marshal(ptr);
if (export == null)
	Max.LogErr("Couldn't get scene export");
	Max.Log("Export is " + export.GetType().FullName);

This shows the basic way that you can get an object reference to the abstract classes defined in IGlobal. The only remaining question is how you get the class id you need to get the native pointer for the object. Here are a few ways to get class ids:

  • Look them up in pluginapi.h (you can find the reference on the web)
  • In maxscript, use .classID
  • Some of them are found in Autodesk.Max.BuildInClassIDA and Autodesk.Max.BuildInClassIDB

That doesn’t help you everywhere, but at least it’s enough to get started!