Creating/Removing Menu itesm

Hi

I am using the following script from the help to create a new menu item:-

if menuMan.registerMenuContext 0x246c6dbe then
(
local mainMenuBar = menuMan.getMainMenuBar()
local helpMenuIndex = mainMenuBar.numItems() 
local helpMenuItem = mainMenuBar.getItem(helpMenuIndex)
local helpMenu = helpMenuItem.getSubMenu()
local sepItem = menuMan.createSeparatorItem()
local testItem = menuMan.createActionItem "MyTest" "Menu Test"
 
helpMenu.addItem sepItem -1
helpMenu.addItem testItem -1
menuMan.updateMenuBar()
)

Now what I want to do is write a script to remove this Menu. In the help it appears that you use unregister, but it then warns you to use extreme caution as you might corrupt your 3ds Max installation. Can anyone help?

Thanks

Gray

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Graph's picture

the MenuContext? subMenu? if

the MenuContext?
subMenu?

if so use something along the lines of:
try (menuMan.unRegisterMenu (menuMan.findMenu "SubMenuName") ) catch()

Raphael Steves

gramx's picture

Thanks Graph I just ment was

Thanks Graph

I just ment was it possible to unregister the unique code that was created by the following line?

if menuMan.registerMenuContext 0x246c6dbe then

When you create a menu this way as in the help than you need to create a new code every time you run the script to add the menu. Anyway I have just skipped out this line and I can now add and remove menus easily.

Ta

G

Graph's picture

heres what i use: local

heres what i use:

			local toolsMenu = getToolsMenu()
			for i = 1 to 20 do
			(
				local fileMenu = (toolsMenu.getItem i).getTitle()
				if fileMenu == "Frowser" do
				(
					toolsMenu.removeItemByPosition  i
					menuMan.updateMenuBar()
				)
			)

getToolsMenu returns the mainMenu/tools submenu mixinInterface
you gotta update on every iteration in case theres freakishly more than one entry
could also use a while loop tho

Raphael Steves

gramx's picture

Cool, that will work,

Cool, that will work, thanks.

I have also been trying to Unregister the MenuContext. I dont think it is possible though.

Anyone got any ideas? Most people seem not to use them anyway!

Thanks

G

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.