Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

[.NET] Custom menu in 3dsMax 2018

[.NET] Custom menu in 3dsMax 2018

Anonymous
Not applicable
1,409 Views
1 Reply
Message 1 of 2

[.NET] Custom menu in 3dsMax 2018

Anonymous
Not applicable

Hello,

I have a Global Utility Plugin which check if a custom menu exists at startup of 3dsMax, and creates it if it's not there. The plugin worked fine in others versions of 3dsMax (tested in 2016 & 2017) but apparently the menu is not registered in 2018 version. Also, the current code doesn't throw any exception.

Here's a sample code : 

IIActionManager actionManager = MaxInterfaces.Ip.ActionManager;
IIMenuManager menuManager = MaxInterfaces.Ip.MenuManager;
menu = menuManager.FindMenu("My Menu");

if (menu != null)
{
    menuManager.UnRegisterMenu(menu);
    MaxInterfaces.Global.ReleaseIMenu(menu);
    menu = null;
}

menu = MaxInterfaces.Global.IMenu;
menu.Title = "My Menu";
menuManager.RegisterMenu(menu, 0);

foreach (IActionItem item in MaxUtils.GetActionsByCategory("My Menu"))
{
    IIMenuItem menuItemAltitude = MaxInterfaces.Global.IMenuItem;
    menuItemAltitude.Title = "&" + item.ButtonText;
    menuItemAltitude.ActionItem = item;
    menu.AddItem(menuItemAltitude, -1);

}

menuItem = MaxInterfaces.Global.IMenuItem;
menuItem.SubMenu = menu;
menuManager.MainMenuBar.AddItem(menuItem, -1);
menuManager.UpdateMenuBar();

The code actually finds my actions related to the category "My Menu", but if I go to the Customize panel, no menu were created, and the main menu bar still the same.

Thank for your help.

 

0 Likes
Accepted solutions (1)
1,410 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

Ok I have finally found a workaround using Delegate called at SystemStartup (thanks to BabylonJS : https://github.com/BabylonJS/Exporters/commit/2240d9b7c00da03897d02ef50090252df6503690

It seems the Start() method from Global Utility Plugin is now called too early, or the registered menus are overwritten or something like that. The workaround consists to instaciate a new delegate during GUP::Start() method, and register it to be called at SystemNotificationCode.SystemStartup. In the delegate handler function, just call the method to create menus like you did in GUP::Start() in previous versions of 3dsMax.