I have a custom plugin for 3ds Max that interfaces with some managed code on the back end. In some circumstances, I'd like to forward along a managed object to MAXScript for direct interaction, i.e. return a wrapped object from one of my functions.
MAXScript is able to manipulate managed objects directly relatively well through another plugin (msxdotNet) included with Max (I'm using 3ds Max 2008). It basically wraps an object and uses reflection for late bound calls, but it is totally self contained and doesn't have any sdk exposure. The plugin dll itself also does not expose anything more than the minimum interface required by Max for adding a few top level scripted classes.
The scripted classes allow one to instantiate a new object via a constructor
local inst = (dotNetObject "MyPlugin.MyClass" 0 0 "arg3")
In my case I already have an instance of an object that I'd like to use.
Is there a way to construct an instance of a dotNetObject wrapper from within my plugin to return to Max?
Idealy, I'd like to have a helper function with a (C++/CLI) signature similar to:
Value* WrapObject(System::Object ^obj);
Some basic guarantees that I can make:
- The msxdotNet plugin is already loaded.
- The msxdotNet plugin and my managed assemblies are in the same AppDomain.
The source for the msxdotNet plugin is included as an sdk sample, but for management/sanity's sake, modifying it and recompiling it is not an option.