How to transfer parameters from/to maxscript

 
 
 
Posted by:ofer_z
Data created:27 July 2010

Hi,

How do I pass and receive parameters from/to maxscript?

I want to call a function from maxscript and pass it some parameters like, e.g., a node, and after processing it with maxDotNet, return some value to back to maxscript.

Thanks,

o

Hi Offer,

Sorry for neglecting your post, somehow I missed it. The way to call a .NET function from MaxScript is outlined here:

http://www.ephere.com/autodesk/max/docs/987.html

I would pass a node using its handle (in MXS: MyFunction( myNode.Handle ) ). The .NET function would take an int and then I'd use IGlobal.COREInterface.GetINodeByHandle( handle ) to get the node. Getting other objects (i.e. a controller) could be a bit trickier, I would do it using an anim. handle but I'm not sure if you can get a node's anim handle from MaxScript.

Returning a value back to MaxScript should be trivial by specifying the .NET function's return value.

 

Marsel Khadiyev (Software Developer, EPHERE Inc.)

Hi Marsel,

Thanks for your answer, and no problem, I wasn't feeling left out :)

I already figured the handle method, but was hoping there would be a better way to pass values of different types directly. I guess I'll have to keep working with workarounds, and perhaps overload the functions.

As for return value, is it possible to return any kind of max value (for example, a material)?

Thanks,

o

Right, unfortunately workarounds is probably the best approach. I've been dealing with MaxScript exposure in C++ a lot previously and it is just as involved/painful and also seems to be on its way out. I am considering of excluding MXS namespace/classes from Max.NET in near future as they take up (largely unused) space.

Return values would need to be handled same as parameters. I just opened MXS reference and I see that there actuall is a way to get objects by anim handle, which makes everything much easier:

In .NET: UIntPtr myHandle = global.Animatable.GetHandleByAnim( myMaterial or anything else );
In MXS: myMaterial = GetAnimByHandle myHandle

Haven't actually tried it, but should work theoretically.

Marsel Khadiyev (Software Developer, EPHERE Inc.)