This command is used for saving the contents of a menu, so that another instance of the menu may be recreated later. The command writes out a file which, when run as a script, will rebuild the menuItems contained in the original menu. Note that the fileName is relative to the user’s marking menu preference directory. Note that this command is used solely by the Marking Menu Editor and is not intended to be used for general purposes. Note that this command doesn’t work well with controls that have mixed mel and python command callbacks. Also, because it saves the menu state to a mel file, it does not work with callbacks that are python callable objects. The first argument is the name of the manu to save, the second one is the name of the file.
Derived from mel command maya.cmds.saveMenu
Example:
import pymel.core as pm
# Create a window with two frames.
#
win = pm.window(title='saveMenu Example')
pm.columnLayout()
# Result: ui.ColumnLayout('window1|columnLayout79') #
frame1 = pm.frameLayout( h=90, l='Original Menu (LMB)' )
pm.text( l='(click here)' )
# Result: ui.Text('window1|columnLayout79|frameLayout22|text7') #
pm.setParent( '..' )
# Result: u'window1|columnLayout79' #
frame2 = pm.frameLayout( h=90, l='Copy of Original (LMB)' )
pm.text( l='(click here)' )
# Result: ui.Text('window1|columnLayout79|frameLayout23|text8') #
pm.setParent( '..' )
# Result: u'window1|columnLayout79' #
# Create a menu.
#
menu1 = pm.popupMenu( parent=frame1, b=1, mm=True )
pm.menuItem( rp='N', l='Up' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem946') #
pm.menuItem( rp='S', l='Down' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem947') #
pm.menuItem( rp='E', l='Right' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem948') #
pm.menuItem( rp='W', l='Left' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem949') #
pm.menuItem( label='Warm', sm=True )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem950') #
pm.menuItem( l='Red' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem950|menuItem951') #
pm.menuItem( l='Orange' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem950|menuItem952') #
pm.menuItem( l='Yellow' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem950|menuItem953') #
pm.setParent( '..', m=True )
# Result: u'window1|columnLayout79|frameLayout22|popupMenu93' #
pm.menuItem( label='Cold', sm=True )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem954') #
pm.menuItem( l='Green' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem954|menuItem955') #
pm.menuItem( l='Blue' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem954|menuItem956') #
pm.menuItem( l='Indigo' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem954|menuItem957') #
pm.menuItem( l='Violet' )
# Result: ui.CommandMenuItem('window1|columnLayout79|frameLayout22|popupMenu93|menuItem954|menuItem958') #
pm.setParent( '..', m=True )
# Result: u'window1|columnLayout79|frameLayout22|popupMenu93' #
pm.setParent( '..', m=True )
# Result: u'' #
# Save the menu to a file.
#
result = pm.saveMenu(menu1, 'menu_example')
# Use the file to rebuild another instance of the menu.
#
menu1 = pm.popupMenu( parent=frame2, b=1, mm=True )
maya.mel.eval( 'source \"' + pm.internalVar(userMarkingMenuDir=True) + 'menu_example.mel\"' )
# Result: u'' #
# Finish up.
print ("The menu was saved in [" + pm.internalVar(userMarkingMenuDir=True) + result + "]\n" )
pm.showWindow( win )
pymel.core.windows.saveAllShelves
pymel.core.windows.savePrefObjects
Enter search terms or a module, class or function name.