MenuMan sub menu menus

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2013   #1
MenuMan sub menu menus

Hi

I have been wrapping my head around max`s menus with menuMan and think I just about get the basics but im having trouble adding menus that expand to other menus.

To see what i mean have a look at the modifiers menu in max`s main tool bar, every one has an arrow to expand into another menu.

Could someone show me how to do this pleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeease

thanks
 
Old 02 February 2013   #2
Originally Posted by broomy: Could someone show me how to do this pleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeease

show what you have and i will help you to make it works.
 
Old 02 February 2013   #3
I hope this works, i have just thrashed it out at home, its late now and havent tried it,
I shall update it with the actual code i have done at work tomorrow but it is definitely the gist of what i have written at work

in each script im creating a tag that im going to be using to separate the menuas out
ie modeling uvs materials etc...

something along the lines of
for each mcr
find tag
add to relevant sub menu

scriptsDir = getDir #scripts
  mcrScripts = getFiles (scriptsDir + "\\Startup\\*.mcr")
  for f in mcrScripts do
  (
  	fileIn f
  )
  
  mainMenuBar = menuMan.getMainMenuBar()
  toolsMenu = menuMan.createMenu "ToolsMenu"
  
 local toolsMenu
 
  for i = 1 to mcrScripts.count do
  (
  	macroName = getMacroName mcrScripts[i]--returns a string
  
  	item = menuMan.createActionItem macroName "Tools"
  
 	toolsMenu.addItem item -1
  
 	toolsMenuItem = menuMan.createSubMenuItem "Test Menu" toolsMenu
  
 	
  )
 
 mainMenuBarItems = mainMenuBar.numItems() -1--zero based
 
 mainMenuBar.addItem toolsMenu mainMenuBarItems
 
  menuMan.updateMenuBar()


Updated so it might actually work (without sub menus)

Last edited by broomy : 02 February 2013 at 01:20 PM.
 
Old 02 February 2013   #4
now i see that you've tried do it at least
here is a sample how to do it... try to understand how it works yourself.

(
	menu = menuMan.createMenu "Custom Tools"
	sub = menuMan.createMenu "Apply Modifier"

	a = menuMan.createActionItem "Bend" "Modifiers"
	sub.addItem a -1
	b = menuMan.createActionItem "Taper" "Modifiers"
	sub.addItem b -1

	item = menuMan.createSubMenuItem "Apply Modifier" sub

	menu.addItem item -1
	mitem = menuMan.createSubMenuItem "Custom Tools" menu
	index = mainMenuBar.numItems() -- add before last (usualy it's "Help")
	mainMenuBar.addItem mitem index

	menuMan.updateMenuBar()
)   
 
Old 02 February 2013   #5
cheers denis

my code (at work at least) does work and it only supposed to create a single long list of all the scripts in our startup folder,which it does

thanks for the example code works like a charm
I should have figured that out, might have been staring at it too long

cheers
 
Old 02 February 2013   #6
fn createCatagorizedMenu = 
(
	lMenu = menuMan.findMenu "Tools"

	if lMenu != undefined do
	(
		menuMan.unRegisterMenu lMenu
		menuMan.updateMenuBar()
		lMenu = menuMan.findMenu "Tools" -- need to check it again after destroying the menu
	)
	
	if lMenu == undefined do
	(
		toolTypes = #()
		mcrMacros = getFiles (scriptsDir + "\\Startup\\*.mcr")
		for i = 1 to mcrMacros.count do
		(
			toolType = getToolType mcrMacros[i]
			appendIfUnique toolTypes toolType
		)

		mainMenuBar = menuMan.getMainMenuBar()--main toolbar
		ToolsMenu = menuMan.createMenu "Tools" -- create menu object

		for type in toolTypes do
		(
			subMenu = menuMan.createMenu type

			for i = 1 to mcrMacros.count do
			(
				toolType = getToolType mcrMacros[i]--returns a custom tag
				if toolType == type do
				(
					scriptName = getMacroScriptName mcrMacros[i]--returns the macroscript name
					
					item = menuMan.createActionItem scriptName "Tools"
					subMenu.addItem item -1
				)
			)

			subItem = menuMan.createSubMenuItem type subMenu
			ToolsMenu.addItem subItem -1
		)
		
		index = mainMenuBar.numItems()
		
		ToolsItem = menuMan.createSubMenuItem "Tools" ToolsMenu
		
		mainMenuBar.addItem ToolsItem index

		menuMan.updateMenuBar()
	)
)


thanks denis
 
Old 02 February 2013   #7
i can't test it without getToolType and getMacroScriptName functions but everything looks right...
except... it works for situation 'one-file - one-macro' which is not always true.
the right way is to use macros.list. it's undocumented but you can redirect list output to any stream. after that just parse the data, find your macros by file, category, whatever... and make menus:

ss = stringstream ""
macros.list to:ss
ss as array
 
Old 02 February 2013   #8
yeah sorry cant really post the entire file but it does work as do the other functions

as for macros.list(), i didnt know about that functionality, just recently returned to Mxs, been doing it 4 days now after pymel for a few years

getMacroScriptName() goes through the mcr file string stream and finds the macrosript sting, then the name is the next value and I know the category already. Its a a fairly heavy function for just that info so maybe macros.list() will be better, i shall investigate more tomorrow.

getToolType() does a similar thing but searches for a string that will be the categories my studio wants to use and returns that string to populate the menus with

As for 'one-file - one-macro' thats the way im intending to do the mcr`s, i have a few ms scripts at the moment and im wrapping them in a simple macrosript with a fileIn of the ms to have the ability to run it from code and via the UI, BUT im not saying it wont change in the future

From what i have learnt in the menuMan :-
any menuObject can have action items
that menu can be "converted" into a sub menu item (createSubMenuItem)
that sub menu item can then be added to a parent menu object
rinse and repeat for however deep a menus you want

this conversion is what seemed odd to me with the MenuObeject and the Item being so similar in the docs, the subject is quite simple really but the documentation/naming could be vastly improved imho

anywho thanks for the help
 
Old 02 February 2013   #9
Originally Posted by broomy: as for macros.list(), i didnt know about that functionality...

just play with it and you will see how i'm right. the best
 
Old 02 February 2013   #10
i do like the smiley
 
Old 02 February 2013   #11
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:33 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.