.NET Action Items

It is now possible to create custom action items in a .NET assembly. This is done by creating a public class that implements the interface ICuiActionCommand (found in MaxCustomControls.dll) and placing the DLL containing the implemented interface in the bin\assemblies folder. 3ds Max will then dynamically load an instance of this class as an action in its CUI interface. When the action is executed by 3ds Max the method ICommand.Execute() will be called on the loaded class.

To simplify the construction of .NET custom actions, a custom class can inherit from the abstract base class CuiActionCommandAdapter. In the code samples below, we provide an example of such an inheritance using VB.NET and C#. For more information, consult the .NET reference guide.

VB.NET

Imports Autodesk.Max
Imports MaxCustomControls

Public Class Class1
    Inherits CuiActionCommandAdapter

    Public Overrides ReadOnly Property ActionText As String
        Get
            Return InternalActionText
        End Get
    End Property
    Public Overrides ReadOnly Property InternalActionText As String
        Get
            Return "Action 1"
        End Get
    End Property
    Public Overrides ReadOnly Property Category As String
        Get
            Return InternalCategory
        End Get
    End Property
    Public Overrides ReadOnly Property InternalCategory As String
        Get
            Return "ADN Samples"
        End Get
    End Property
    Public Overrides Sub Execute(parameter As Object)
        Dim myglobal As IGlobal = Autodesk.Max.GlobalInterface.Instance
        Dim ip As IInterface13 = myglobal.COREInterface13

        ip.PushPrompt("Hello 3ds Max .Net API!")

    End Sub
End Class

C#

public class MaxDotNetCUIDemo : CuiActionCommandAdapter {
    public override string ActionText {
        get { return InternalActionText; }
    }

    public override string Category {
        get { return InternalCategory; }
    }

    public override void Execute(object parameter) {
        Autodesk.Max.Global.Instance.COREInstance13.AddPrompt("Yeeehaaaaaaaaaa!");
    }

    public override string InternalActionText {
        get { return "Prompt me!"; }
    }

    public override string InternalCategory {
        get { return "3ds Max .NET Demo"; }
    }
}