» Back to Documentation

3ds Max provides hooks into its SDK that allow events such as scene saving/loading, undo/redo, Max startup/shutdown, object creation and many others to be called into the plugins. This is a very useful functionality that allows plugins to be responsive to 3dsmax UI rather than just rely on its own UI.

Here is a simple way to register and, optionally, unregister such an event callback as a delegate in your C# code:

  1. Register your event function. This can be either static or a class member function:

    void Global_SystemShutdown( IntPtr obj, IntPtr info )
            {
                    // Do something...
            }
  2. Create a delegate member inside your class to track instance of our shutdown delegate:

    GlobalDelegates.Delegate3 systemShutdownHandler;
  3. Hook the function up to 3dsmax, this must be done only once:

    this.systemShutdownHandler = new GlobalDelegates.Delegate3( this.Global_SystemShutdown );
    global.RegisterNotification( this.systemShutdownHandler, null, SystemNotificationCode.SystemShutdown );
  4. Optionally, later you can unregister the event to stop receiving notifications:

    global.UnRegisterNotification( this.systemShutdownHandler, null, SystemNotificationCode.SystemShutdown );

That is all there is to it! Have a look at SystemNotificationCode enumeration for a list of available global events.