You can create an action to customize the user interface, such as the 3ds main menu or toolbars. Use the ActionFactory.Create() method to create your action. You can customize the menu text, button text, description text, visibility and so forth for your action. An ActionItem is created. To execute your action, use the ActionItem.Execute() method, for example, as follows: ~ import MaxPlus
def doSomething(): print "I sleep all night and I work all day!"
action = MaxPlus.ActionFactory.Create('Do something', 'Python demo', doSomething) action.Execute() ~
See demoActionFactory.py for an example of creating an action.
The process of creating a menu can be outlined as follows:
Create your action as follows: action = MaxPlus.ActionFactory.Create('Do something', 'Python demos', doSomething)
Create your MenuBuilder: mb = MaxPlus.MenuBuilder(MenuName)
Use the MenuBuilder methods to add your action and a separator: mb.AddItem(action) mb.AddSeparator()
Use the MenuBuilder.Create() method to create your menu:
menu = mb.Create(MaxPlus.MenuManager.GetMainMenu())
A Menu is created.
See demoMenu.py for an example of how to create a new menu 'Test' and unregister and remove it.
This example first removes any previously created menus named 'Test', then prints out a list of all menu items in 3dsMax. It then creates an action and a new menu, and prints out again a list of all menu items. You can see from the list that a new 'Test' menu has been created.
The example then unregisters the newly created menu and removes it, and prints out a list of all menu items again. You can see from the list that the menu has been successfully removed.