Notifications
Clear all
[Closed] Adding custom menu in main menubar
Nov 06, 2020 9:34 am
I want to create a menu in 3ds Max and add it to the main menu bar of 3ds Max using maxscript. How would I do this reading a xml file configured like this…
mymenu.xml
<MainMenu title="TEST">
<Menu title="TEST_FRUIT">
<Menu title="TEST_APPLE"></Menu>
<Menu title="TEST_ORANGE"></Menu>
</Menu>
<Menu title="TEST_FOOD">
<Menu title="TEST_SUISHI"></Menu>
<Menu title="TEST_CHICKEN">
<Menu title="TEST_CHICKEN_FAJITAS"></Menu>
<Menu title="TEST_CHICKEN_TINGA"></Menu>
</Menu>
</Menu>
</MainMenu>
to create a menu that looks like this in 3ds max?
1 Reply
Nov 06, 2020 9:34 am
fn CreateMenu Name:"Name" Title:"Title" ParentMenu: =
(
menuItem = menuMan.CreateMenu Name
menuItem.setTitle Title
subMenuItem = menuMan.createsubMenuItem Name menuItem
if ParentMenu != undefined do ParentMenu.addItem subMenuItem -1
menuItem
)
fn RecursiveAddMenu XmlNode ParentMenu =
(
for i = 0 to XmlNode.ChildNodes.count - 1 do
(
childNode = XmlNode.ChildNodes.ItemOf i
title = childNode.GetAttribute "title"
Menu = CreateMenu Name:title Title:title ParentMenu:ParentMenu
RecursiveAddMenu childNode Menu
)
)
xmlDoc = dotNetObject "System.Xml.XmlDocument"
xmlDoc.load @"C:\Users\New\Desktop\Temp\Menu.xml"
mainMenu = menuMan.getMainMenuBar()
RecursiveAddMenu xmlDoc mainMenu
menuMan.updateMenuBar()