Sometimes it is desirable to have a function defined in your .NET code that you want to call from MaxScript. This is useful for extending MaxScript by adding your own functionality that interacts with its objects and variables.
This can be achieved relatively easy with Max.NET: we can call any static (or member) function by using MaxScript's .NET exposure. Let us first define our pluggable Max.NET class with a callback function in it:
using Autodesk.Max;
namespace MyProject
{
public class Plugin : IPlugin
{
public void MyCallback()
{
// Do something...
}// IPlugin Implementation...
}
}
We can then call MyCallback() function from 3dsmax listener or script as follows:
( dotNetObject "MyProject.Plugin" ).MyCallback()