Example #1
0
def show():
    if pm.menu('alfredTools2', exists=True): pm.deleteUI('alfredTools2')

    gMainWindow = pm.melGlobals['gMainWindow']
    
    # 마야 상단에 메뉴 생성
    alfredToolsMenu = pm.menu('alfredTools2', 
        label = "Alfred Tools 2",
        parent = gMainWindow, 
        tearOff = True, 
        allowOptionBoxes = True,
        #familyImage = familyImage,
        #mnemonic = 'alfred', # 뭔지 모르겠음.
        #helpMenu = True,     # help메뉴 뒤로감
        )
    pm.menuItem( dl='Asset', divider=True, p=alfredToolsMenu )
    pm.menuItem( l='Modeling',          p=alfredToolsMenu, en=False )
    pm.menuItem( l='Surfacing',         p=alfredToolsMenu, c=pm.Callback( menuCmd_surfacing ) )
    pm.menuItem( l='Rigging',           p=alfredToolsMenu, c=pm.Callback( menuCmd_rig ) )
    pm.menuItem( dl='Layout', divider=True, p=alfredToolsMenu )
    pm.menuItem( l='Shot',              p=alfredToolsMenu, c=pm.Callback(menuCmd_layout) )
    pm.menuItem( dl='Animation', divider=True, p=alfredToolsMenu )
    pm.menuItem( l='Animation',         p=alfredToolsMenu, en=False  )
    pm.menuItem( l='Motion Capture',    p=alfredToolsMenu, c=pm.Callback( menuCmd_motionCapture ) )
    pm.menuItem( dl='FX', divider=True, p=alfredToolsMenu )
    pm.menuItem( l='FX',                p=alfredToolsMenu, en=False ) 
    pm.menuItem( dl='Render', divider=True, p=alfredToolsMenu )
    pm.menuItem( l='Scene Assembly',    p=alfredToolsMenu, c=pm.Callback(menuCmd_sceneAssembly) )
    pm.menuItem( l='Surfacing',         p=alfredToolsMenu, c=pm.Callback( menuCmd_surfacing ) )
    pm.menuItem( l='Lighting',          p=alfredToolsMenu, en=False )       
    pm.menuItem( l='Render',            p=alfredToolsMenu, c=pm.Callback(menuCmd_render) )
Example #2
0
def show( reset=False ):
    if pm.about(batch=True):
        print 'menu not available in batch mode.'
        return
    else:
        # -- get things ready for building the menu

        menu_name = "Impress Example"
        pm.setParent( MAYA_WINDOW )

        if pm.menu( menu_name, exists=True ):
            if reset:
                pm.deleteUI( menu_name )
            else:
                main_menu = pm.menu( menu_name, edit=True )
                return main_menu

        if not pm.menu( menu_name, exists=True ):
            main_menu = pm.menu( menu_name, tearOff=True )

        # -- build the menu

        with  main_menu:
            with pm.subMenuItem( 'Display', aob=True, tearOff=True ):
                ui.commandMenuItem( performExample )
Example #3
0
def mantraMainMenu():
    log.debug("Creating mantra main menu")
    menuName = "Mantra"
    if pm.menu(menuName, query=True, exists=True):
        pm.deleteUI(menuName)
    gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow')
    mantraMenu = pm.menu(menuName, label=menuName, parent=gMainWindow, tearOff=True)
    pm.menuItem(label='Create Geo Standin', command=pm.Callback(menuCallback, "GeoStandin"))
    pm.setParent("..", menu=True)
Example #4
0
def create_tank_disabled_menu(menu_name):
    """
    Render a special "shotgun is disabled menu"
    """
    if pm.menu("ShotgunMenu", exists=True):
        pm.deleteUI("ShotgunMenu")

    sg_menu = pm.menu("ShotgunMenuDisabled", label=menu_name, parent=pm.melGlobals["gMainWindow"])
    pm.menuItem(label="Sgtk is disabled.", parent=sg_menu, 
                command=lambda arg: tank_disabled_message())
Example #5
0
def ui():
    if pm.window("Depth tool", q=True, exists=True):
        pm.deleteUI("Depth tool")
    with pm.window("Depth tool", menuBar=True, s=False):
        pm.menu(l="help")
        pm.menuItem(l="document", c=pm.Callback(os.system, "D:/Users/blood/Desktop/eyeTest_01.mov"))
        pm.menuItem(l="tutorial", c=pm.Callback(pm.launch, web="https://www.youtube.com/watch?v=-JwXfnrX1wM"))
        with pm.columnLayout(adj=True):
            with pm.rowLayout(nc=2):
                pm.button(l="Create" + "\n" + "Depth", w=64, h=64, bgc=(0.2, 0.2, 0.2), c=creatAll)
                pm.button(l="Adjust" + "\n" + "Min&&Max", w=64, h=64, bgc=(0.8, 0.8, 0.8), c=adjustAll)
 def __init__(self):
     if pm.window(self.uiID, exists=True):
         pm.deleteUI(self.uiID)
     win = pm.window(self.uiID, title=self.title, menuBar=True)
     with win:
         pm.menu( label='CageDeformer', tearOff=True )
         pm.menuItem( label="CageDeformer", c=pm.Callback( self.initPlugin, "cage") )
         pm.menuItem( label="CageDeformerARAP", c=pm.Callback( self.initPlugin, "cageARAP") )
         self._parentLayout = pm.columnLayout( adj=True )
         with self._parentLayout:
             self.createUISet()
def lcCameraToolsUI(dockable=False, *args, **kwargs):
  ''' '''
  ci = 0 #color index iterator
  windowName = 'lcCameraTools'
  shelfCommand = 'import lct.src.lcCameraTools.lcCameraTools as lcCam\nreload(lcCam)\nlcCam.lcCameraToolsUI()'
  icon = basePath+'lcCameraTools.png'
  winWidth  = 204
  winHeight = 209
  
  mainWindow = lcWindow(windowName=windowName, width=winWidth, height=winHeight, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True)
  mainWindow.create()
  pm.menu(l='Options', helpMenu=True)
  pm.menuItem(l='Reset Gradient Colors', command=lambda *args: cam_set_default_colors() )

  #
  pm.columnLayout(prefix+'_columLayout_main')
  
  #
  pm.rowColumnLayout(nc=2, cw=([1,50], [2,150]) )
  pm.text(l='Edit:', al='right')
  cameraListDropdown = pm.optionMenu(prefix+'_optionMenu_camera_list', bgc=colorWheel.getColorRGB(ci), w=150, h=25 )
  ci+=1
  cameraListDropdown.changeCommand(lambda *args: cam_get_cam_attrs(cameraListDropdown) )
  pm.setParent(prefix+'_columLayout_main')
  
  #  
  pm.rowColumnLayout(nc=2, cw=([1,125], [2,75]) )
  pm.text(l='Focal Length:', al='right')
  pm.floatField(prefix+'_floatField_focal_length', min=0.0, v=0.0, pre=1, w=75, changeCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown), receiveFocusCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown) )
  pm.text(l='Near Clip Plane:', al='right')
  pm.floatField(prefix+'_floatField_near_clip_plane', min=0.0, v=0.0, pre=4, w=75, changeCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown), receiveFocusCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown) )
  pm.text(l='Far Clip Plane:', al='right')
  pm.floatField(prefix+'_floatField_far_clip_plane', min=0.0, v=0.0, pre=0, w=75, changeCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown), receiveFocusCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown) )
  pm.text(l='Overscan:', al='right')
  pm.floatField(prefix+'_floatField_overscan', min=0.0, v=0.0, pre=3, w=75, changeCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown), receiveFocusCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown) )
  pm.text(l='Background Color:', al='right')
  pm.colorSliderGrp(prefix+'_colorSliderGrp_background_color', cw1=50, rgb=(0.0,0.0,0.0), changeCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown) )
  pm.text(l='Gradient Top:', al='right')
  pm.colorSliderGrp(prefix+'_colorSliderGrp_gradient_top', cw1=50, rgb=(0.54,0.62,0.70), changeCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown) )
  pm.text(l='Gradient Bottom:', al='right')
  pm.colorSliderGrp(prefix+'_colorSliderGrp_gradient_bottom', cw1=50, rgb=(0.1,0.1,0.1), changeCommand=lambda *args: cam_set_cam_attrs(cameraListDropdown) )
  pm.setParent(prefix+'_columLayout_main')
  
  #
  pm.rowColumnLayout(nc=2, cw=([1,175], [2,25]) )
  pm.button(prefix+'_button_toggle_bkgd', l='Toggle Background', bgc=colorWheel.getColorRGB(ci), w=200, h=25, annotation='Toggle between flat color and gradient background', command=lambda *args: camera.toggleBackground() )
  ci+=1
  pm.iconTextButton(w=25, h=25, style='iconOnly', image=iconBasePath+'addToShelf.png', highlightImage=iconBasePath+'addToShelf_over.png', annotation='Add to Shelf', command=lambda *args: shelf.makeShelfButton('Toggle Camera Background', 'from lct.src.core.lcUtility import Camera as camera\ncamera.toggleBackground()', iconBasePath+'toggleBackground.png', "Toggle Camera's Viewport Background") )

  #
  mainWindow.show()
  
  cam_populate_camera_list(cameraListDropdown)  
  cam_get_cam_attrs(cameraListDropdown)
 def __init__(self):
     if pm.window(self.uiID, exists=True):
         pm.deleteUI(self.uiID)
     win = pm.window(self.uiID, title=self.title, menuBar=True)
     with win:
         pm.menu( label='Create', tearOff=True )
         for type in deformerTypes:
             pm.menuItem( label=type, c=pm.Callback( self.initPlugin, type) )
         self._parentLayout = pm.columnLayout( adj=True )
         with self._parentLayout:
             self.createUISet()
Example #9
0
 def __init__(self):
     if pm.window(self.uiID, exists=True):
         pm.deleteUI(self.uiID)
     win = pm.window(self.uiID, title=self.title, menuBar=True)
     with win:
         pm.menu(label='CageDeformer', tearOff=True)
         for type in deformerTypes:
             pm.menuItem(label=type, c=pm.Callback(self.initPlugin, type))
         self._parentLayout = pm.columnLayout(adj=True)
         with self._parentLayout:
             self.createUISet()
    def __init__(self):
        if pm.window(self.uiID, exists=True):
            pm.deleteUI(self.uiID)

        win = pm.window(self.uiID, title=self.title, menuBar=True)
        with win:
            pm.menu(label='Plugin', tearOff=True)
            pm.menuItem(label="Create", c=pm.Callback(self.initPlugin))
            self._parentLayout = pm.columnLayout(adj=True)
            with self._parentLayout:
                self.createUISet()
Example #11
0
    def create(self, *args, **kwargs):
        ''' '''
        if pm.control(self.windowName, exists=True):
            pm.deleteUI(self.windowName)
        if pm.control(self.dockName, exists=True):
            pm.deleteUI(self.dockName)

        if self.dockable:
            self.mainWindow = pm.window(self.windowName, t=self.windowName)
        else:
            self.mainWindow = pm.window(self.windowName, t=self.windowName, widthHeight=[self.width, self.height],
                                        rtf=self.rtf, mnb=self.mnb, mxb=self.mxb, s=self.sizeable, **self.kwargs)

        if self.menuBar:
            self.menuBarLayout = pm.menuBarLayout(self.prefix + '_menuBarLayout')
            #### Help menu
            pm.menu(self.prefix + '_help', l='Help', helpMenu=True)
            pm.menuItem(parent=self.prefix + '_help', l='Online Help', image='help.png',
                        command=lambda *args: webbrowser.open('http://lct.leocov.com/help', new=2))
            pm.menuItem(parent=self.prefix + '_help', l='Contact / Bug Report',
                        image=os.path.join(self.srcPath, 'icons', 'lc_bug.png'),
                        command=lambda *args: self.bug_report_window())
            errorLogMenuItem = pm.menuItem(parent=self.prefix + '_help', l='Send Error Logs',
                                           checkBox=self.global_cfg.get('g_send_errors'),
                                           annotation="Automatically send error logs to the developer",
                                           command=lambda *args: self.global_cfg.set('g_send_errors',
                                                                                     pm.menuItem(errorLogMenuItem,
                                                                                                 q=True,
                                                                                                 checkBox=True)))
            updateMenuItem = pm.menuItem(parent=self.prefix + '_help', l='Update', enable=False, image='',
                                         command=lambda *args: lcUpdate.Update.lct_auto_update(confirmDiag=True))
            pm.menuItem(parent=self.prefix + '_help', l='About', image='channelBox.png',
                        command=lambda *args: self.about())
            #### Options menu
            pm.menu(self.prefix + '_options', l='Options')
            sceneSettingsMenuItem = pm.menuItem(parent=self.prefix + '_options', l="Use scene settings node",
                                                checkBox=self.global_cfg.get('g_scene_settings'),
                                                annotation="Store tool settings in a scene node. This applies to all scenes.",
                                                command=lambda *args: self.global_cfg.set('g_scene_settings',
                                                                                          pm.menuItem(
                                                                                              sceneSettingsMenuItem,
                                                                                              q=True, checkBox=True)))
            pm.menuItem(parent=self.prefix + '_options', l='Reset {0}'.format(self.windowName), image='airField.svg',
                        command=lambda *args: self.lct_cfg.reset_tool_config(self.windowName))
            # pm.menuItem(parent = self.prefix+'_options', l='Make Shelf Icon', command=lambda *args: lcShelf.Shelf.makeShelfButton(self.windowName, self.shelfCommand, self.icon, self.annotation) )

            # get the current toolset version and release codes
            release, version = lcUpdate.Update.update_get_current_version()
            if release:
                # check if there is a new version on the server and get it
                updatePath = lcUpdate.Update.update_get_new_version(version=version, release=release)
                if updatePath:
                    pm.menuItem(updateMenuItem, edit=True, l='Update Available', enable=True,
                                image='activeSelectedAnimLayer.png')
Example #12
0
    def createMenu(self):
        print 'initiating session'
        if pm.menu('PipeMenu', exists=True):
            pm.deleteUI('PipeMenu')

        pm.menu('PipeMenu', label='PipeMenu', p='MayaWindow', to=True)
        pm.menuItem(label="Browser", command=self.browserCallback)
        pm.menuItem(label="Publish Scene", command=self.publishCallback)
        pm.menuItem(label="Update Scene", command=self.sceneCheckCallback)
        pm.menuItem(label="scriptJob Update Scene",
                    command=self.scriptJobSceneCheckCallback)
        pm.menuItem(label="scriptJob kill", command=self.killall)
Example #13
0
def mantraMainMenu():
    log.debug("Creating mantra main menu")
    menuName = "Mantra"
    if pm.menu(menuName, query=True, exists=True):
        pm.deleteUI(menuName)
    gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow')
    mantraMenu = pm.menu(menuName, label = menuName, parent = gMainWindow, tearOff = True )
    pm.menuItem( label = 'AttributeManager', command = Callback(menuCallback, "AttributeManager") )
    pm.menuItem( label = 'DummyMenu' , command = Callback(menuCallback, "Dummy") )
    pm.menuItem( label = '', divider = True )
    pm.menuItem( label = 'DummyMenuA' , command = Callback(menuCallback, "DummyA") )
    pm.setParent("..", menu = True)
Example #14
0
def add_ldt_menus():
    """Add Look dev Tools menus to dccs."""
    from ldt import context
    dcc = context.dcc()
    if dcc == 'Maya':
        import pymel.core as pm
        if pm.menu('LookDevTools', l=u'LookDevTools', ex=True):
            logger.info('menu already exists.')
        else:
            pm.menu('LookDevTools', l=u'LookDevTools', to=True)
            pm.menuItem(l=u'Open', c='import ldt;reload(ldt)')
            pm.setParent("..")
Example #15
0
    def update_shelf_top_menu(menu):
        """
        Populate the shelves menu with one menu item per shelf tab.
        """
        # Clear the menu so it can be repopulated.
        pm.setParent(menu, menu=True)
        pm.menu(menu, e=True, deleteAllItems=True)

        shelves = Shelf.get_shelves()

        for shelf in shelves:
            create_shelf_button_menu(shelf, menu)
Example #16
0
def unload_menus( ):
    # Get gMainWindow from mel command
    main_window = mel.eval("$temp=$gMainWindow")
    # search and delete old menuName
    menu_list = pm.window(main_window, query=True, menuArray=True)
    
    for menu in menu_list:
        if menu == menu_name:
            pm.menu(menu, edit=True, deleteAllItems=True)
            pm.deleteUI(menu)
            print ('Unloading Menu : ' + menu_name)
            break
Example #17
0
def mantraMainMenu():
    log.debug("Creating mantra main menu")
    menuName = "Mantra"
    if pm.menu(menuName, query=True, exists=True):
        pm.deleteUI(menuName)
    gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow')
    mantraMenu = pm.menu(menuName,
                         label=menuName,
                         parent=gMainWindow,
                         tearOff=True)
    pm.menuItem(label='Create Geo Standin',
                command=pm.Callback(menuCallback, "GeoStandin"))
    pm.setParent("..", menu=True)
Example #18
0
def create_tank_disabled_menu(menu_name):
    """
    Render a special "shotgun is disabled menu"
    """
    if pm.menu("ShotgunMenu", exists=True):
        pm.deleteUI("ShotgunMenu")

    sg_menu = pm.menu("ShotgunMenuDisabled",
                      label=menu_name,
                      parent=pm.melGlobals["gMainWindow"])
    pm.menuItem(label="Sgtk is disabled.",
                parent=sg_menu,
                command=lambda arg: tank_disabled_message())
Example #19
0
def mvgCreateMenu():
    gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow')
    menuName = "mvgMenu"
    menuLabel = "MayaMVG"
    if(pm.menu(menuName, exists=True)):
        pm.deleteUI(menuName)
    if(gMainWindow != ""):
        pm.setParent(gMainWindow)
        menu = pm.menu(menuName, label=menuLabel, tearOff=True)
        pm.menuItem(parent=menu, label='Open...', command=pm.Callback(openMVGWindow_CB))
        pm.menuItem(parent=menu, label='Export selection as ABC', command=pm.Callback(exportSelectionAsABC_CB))
        pm.menuItem(parent=menu, label='Create locator from vertex', command=pm.Callback(createLocatorFromVertex_CB))
        pm.menuItem(parent=menu, divider=True)
Example #20
0
 def UI_Build(self):
     """Build the static UI and define the main layouts.
     
     Keyword arguments:
     none
     """
     
     # Delete windows if already existing
     if pc.window("lookdevAssistant", exists=True):
         pc.deleteUI("lookdevAssistant")
     
     # Main window
     self.globalWidgets['window'] = pc.window("lookdevAssistant", menuBar=True, title="Arnold Lookdev assistant", sizeable=False, h=430, w=500)
     
     # Menu bar
     # |-- Creation Menu
     self.globalWidgets['windowMenuCreate'] = pc.menu(label="Create")
     pc.menuItem(label='new aiStandard', parent=self.globalWidgets['windowMenuCreate'], c=partial(self.Maya_createNode, 'aiStandard'))
     pc.menuItem(label='new File', parent=self.globalWidgets['windowMenuCreate'], c=partial(self.Maya_createNode, 'file'))
     pc.menuItem(label='new ygColorCorrect', parent=self.globalWidgets['windowMenuCreate'], c=partial(self.Maya_createNode, 'ygColorCorrect'))
     pc.menuItem(divider=True)
     # --|-- Create complete network Menu
     self.globalWidgets['completeNetworkMenu'] = pc.menuItem(label='Complete network', parent=self.globalWidgets['windowMenuCreate'], subMenu=True, pmc=self.UI_refreshMenu)
     self.globalWidgets['fromFile'] = pc.menuItem(l="from existing File...", subMenu=True, p=self.globalWidgets['completeNetworkMenu'])
     pc.menuItem(l="from new File", c=partial(self.Maya_createFullNetwork, False, ''), p=self.globalWidgets['completeNetworkMenu'])
     
     
     # |-- See on flat Menu
     self.globalWidgets['windowMenuSeeOnFlat'] = pc.menu(label="See on flat")
     pc.menuItem(label='Diffuse Color', parent=self.globalWidgets['windowMenuSeeOnFlat'], c=partial(self.Maya_focusOn, 'color'))
     pc.menuItem(label='Specular Color', parent=self.globalWidgets['windowMenuSeeOnFlat'], c=partial(self.Maya_focusOn, 'KsColor'))
     pc.menuItem(label='Specular Roughness', parent=self.globalWidgets['windowMenuSeeOnFlat'], c=partial(self.Maya_focusOn, 'specularRoughness'))
     pc.menuItem(label='Bump', parent=self.globalWidgets['windowMenuSeeOnFlat'], c=partial(self.Maya_focusOn, 'normalCamera'))
     pc.menuItem(divider=True, parent=self.globalWidgets['windowMenuSeeOnFlat'])
     pc.menuItem(label='Revert to aiStandard', parent=self.globalWidgets['windowMenuSeeOnFlat'], c=self.Maya_revertToAiStd)
     
     # Main layout : 2 columns / 1 for the list of the ai* shaders / 1 to access selected shader attributes
     self.globalWidgets['mainLayout'] = pc.rowColumnLayout(nc=2, cw=[(1, 150), (2, 240)])
     
     # Shaders list layout
     self.globalWidgets['sListLayout'] = pc.frameLayout(label='Shaders list', borderStyle='etchedIn', cll=True, h=430 , parent=self.globalWidgets['mainLayout'])
     self.sListWidgets['layout'] = pc.columnLayout(parent=self.globalWidgets['sListLayout'])
     self.sListWidgets['list'] = pc.textScrollList(h=340, parent=self.sListWidgets['layout'])
     self.sListWidgets['listRefreshButton'] = pc.button(l='Refresh', w=95, c=self.UI_refreshShaders)
     
     # Shaders attributes layout
     self.globalWidgets['sAttrLayout'] = pc.frameLayout(label='Shaders attributes', borderStyle='etchedIn', cll=True, h=430, parent=self.globalWidgets['mainLayout'])
     
     # Setup all callbacks
     self.UI_Callbacks()
Example #21
0
def create_sgtk_disabled_menu(menu_name):
    """
    Render a special "shotgun is disabled" menu
    """
    if cmds.about(batch=True):
        # don't create menu in batch mode
        return
    
    if pm.menu("ShotgunMenu", exists=True):
        pm.deleteUI("ShotgunMenu")

    sg_menu = pm.menu("ShotgunMenuDisabled", label=menu_name, parent=pm.melGlobals["gMainWindow"])
    pm.menuItem(label="Sgtk is disabled.", parent=sg_menu, 
                command=lambda arg: sgtk_disabled_message())
Example #22
0
def create_sgtk_disabled_menu(menu_name):
    """
    Render a special "shotgun is disabled" menu
    """
    if cmds.about(batch=True):
        # don't create menu in batch mode
        return

    if pm.menu("ShotgunMenu", exists=True):
        pm.deleteUI("ShotgunMenu")

    sg_menu = pm.menu("ShotgunMenuDisabled", label=menu_name, parent=pm.melGlobals["gMainWindow"])
    pm.menuItem(label="Sgtk is disabled.", parent=sg_menu,
                command=lambda arg: sgtk_disabled_message())
Example #23
0
    def _add_standalone_menu_item(self, name, top_level_path, *args, **kwargs):
        if not _menu_registration.show_top_level_menu:
            return None
        assert 'top_level_path' not in kwargs

        # Make sure the edit menu is built so we can add to it.  Maya defers this
        # for "heap memory reasons", but that was in 2009 and it doesn't really
        # make sense anymore.
        pm.mel.eval('buildDeferredMenus')

        path_parts = top_level_path.split('|')
        assert len(path_parts) >= 1, top_level_path

        # Find or create our menu.
        parent_submenu = 'zMayaTools_Menu'

        pm.setParent('MayaWindow')

        # Create the top-level menu.
        if not pm.menu(parent_submenu, q=True, exists=True):
            item = pm.menu(parent_submenu, label='zMayaTools', tearOff=True)

        # All but the final entry in top_level_path is a submenu name.  Create
        # the submenu tree.
        path_so_far = []
        for part in path_parts[:-1]:
            path_so_far.append(part.replace(' ', '_'))

            # Prefix the submenu to make sure it's unique.
            submenu_item_name = 'zMayaTools_Menu_' + '_'.join(path_so_far)

            # We can add menu items in any order.  Make the menu ordering consistent: always put
            # submenus above regular menu items, and sort alphabetically within that.
            submenu_items = pm.menu(parent_submenu, q=True, ia=True)
            if submenu_item_name not in submenu_items:
                parent_submenu = self._add_menu_item_internal(submenu_item_name, label=part, parent=parent_submenu, subMenu=True, tearOff=True, insert_sorted=True)
            else:
                parent_submenu = submenu_item_name

        # Remove options that only apply when adding the integrated menu item, since
        # we're adding the standalone one.
        kwargs = dict(kwargs)
        kwargs['parent'] = parent_submenu
        if 'insertAfter' in kwargs:
            del kwargs['insertAfter']

        name = '_'.join(path_parts).replace(' ', '_')

        return self._add_menu_item_internal(name, insert_sorted=True, *args, **kwargs)
Example #24
0
def ui():
    #masking이란 윈도우가 있는지를 확인한다. q는 확인하다. exists는 존재여부를 체크한다.
    if pm.window('masking', q=True, exists=True) :
        pm.deleteUI('masking')

    with pm.window('masking',menuBar=True, s=True):
        pm.menu(l='help')
        pm.menuItem(l='document', c=pm.Callback( os.system, "D:/Users/blood/Desktop/eyeTest_01.mov" ))
        pm.menuItem(l='tutorial', c=pm.Callback( pm.launch, web="https://www.youtube.com/watch?v=-JwXfnrX1wM") )
        with pm.columnLayout( adj=True ):
            with pm.rowLayout(nc=4):
                pm.button(l='', w=64, h=64, bgc=(1,0,0), c=redCmd )
                pm.button(l='', w=64, h=64, bgc=(0,1,0), c=greenCmd )
                pm.button(l='', w=64, h=64, bgc=(0,0,1), c=blueCmd)
                pm.button(l='matte', w=64, h=64, bgc=(0.2,0.2,0.2), c=alphaCmd)
    def beginMenu(self):

        cls = self.__class__

        sMayaMainWin = pm.mel.eval('$tempMelVar=$gMainWindow')
        sMenuName = cls.classMenuName

        if pm.menu(sMenuName, q=True, exists=True):
            pm.menu(sMenuName, e=True, dai=True)
            self.menu = pm.ui.PyUI("|".join([sMayaMainWin, sMenuName]))
        else:
            self.menu = pm.menu(sMenuName,
                                label=cls.classMenuLabel,
                                p=sMayaMainWin,
                                to=True)
Example #26
0
    def remove_menu_items(self):
        """
        Remove this menu's menu items.

        This should be overridden by the subclass.
        """
        _menu_registration.unregister_menu(self)

        for item in self.menu_items:
            try:
                pm.deleteUI(item, menuItem=True)
            except RuntimeError:
                continue

            # Walk up the parent submenus, and remove them if they're empty.  This cleans
            # up any submenus we created if all plugins with items inside them are unloaded.
            # Don't recurse all the way up to the top MayaWindow.
            parts = item.split('|')
            for end in xrange(len(parts) - 2, 0, -1):
                # See if the parent menu has any items left.
                parent_menu_path = '|'.join(parts[0:end + 1])
                if len(pm.menu(parent_menu_path, q=True, itemArray=True)) == 0:
                    pm.deleteUI(parent_menu_path)
        self.menu_items = set()
        self.related_items = {}
    def Menubar(self,*args):
	    self.menuBar = pm.menu(parent = 'MayaWindow', label = "Cloth Simulation CIS660", tearOff = True)
            pm.menuItem(label = "Create Cloth", command = self.CreateClothWindow)
            pm.menuItem(label = "Assign the selected objects as Collision Objects with CCD", command = self.AssignCCDCollision)
            pm.menuItem(label = "Assign the selected objects as Collision Objects with regular method", command = self.AssignRegularCollision)
            pm.menuItem(label = "Add a Sphere Collision object(basic method)", command = self.AddSphere)
            pm.menuItem(label = "Select the Solver", command = self.SelectSolver)
 def build_options_menu( self ):
   pmc.setParent( menu = True )
   
   menu = pmc.menu( label = 'Options', allowOptionBoxes = True )
   
   pmc.menuItem( label = 'Set xNormal Location',
                 command = self.set_xn_location )
   
   pmc.menuItem( divider = True )
   
   enable = utils.get_bake_normals( )
   if enable == None:
     utils.set_bake_normals( True )
     enable = True
   pmc.menuItem( label = 'Bake Normal Map',
                 cb = enable,
                 command = pmc.CallbackWithArgs( self.map_cbx_callback,
                                                 'normal' ) )
   enable = utils.get_bake_ao( )
   if enable == None:
     utils.set_bake_ao( False )
     enable = False
   pmc.menuItem( optionBox = True )
   pmc.menuItem( label = 'Bake Ambient Occlusion Map',
                 cb = enable,
                 command = pmc.CallbackWithArgs( self.map_cbx_callback,
                                                 'ao' ) )
   pmc.menuItem( optionBox = True )
Example #29
0
def removeKrakenMenu():

    mainWindow = maya.mel.eval('$tmpVar=$gMainWindow')
    menus = pm.window(mainWindow, q=True, ma=True)
    if 'Kraken' in menus:
        menuParent = pm.menu('Kraken', query=True, parent=True)
        pm.deleteUI('|'.join([menuParent, 'Kraken']))
Example #30
0
def addMenu():
    print("Loading Pipeline...")
    # Name of the global variable for the Maya window
    MainMayaWindow = pm.language.melGlobals['gMainWindow']
    # Build a menu and parent underthe Maya Window
    customMenu = pm.menu('Carbon Pipeline', parent=MainMayaWindow)
    # Build a menu item and parent under the 'customMenu'
    pm.menuItem(label="Launch Project",
                command="pipeline.maya_tools.MayaProjectLauncher()",
                parent=customMenu)
    pm.menuItem(label="Import",
                command="pipeline.maya_tools.MayaImporter()",
                parent=customMenu)
    pm.menuItem(label="Save",
                command="pipeline.maya_tools.MayaSaver()",
                parent=customMenu)

    pm.menuItem(divider=True, parent=customMenu)

    pm.menuItem(label="Version Up",
                command="pipeline.maya_tools.MayaTools().version_up()",
                parent=customMenu)
    pm.menuItem(label="Create Temporary Copy",
                command="pipeline.maya_tools.MayaTools().open_temp_file()",
                parent=customMenu)
    pm.menuItem(label="Publish",
                command="pipeline.maya_tools.MayaTools().publish()",
                parent=customMenu)
Example #31
0
    def _get_sorted_insertion_point(cls, name, subMenu, parent):
        # Get the label and submenu flag for the menu items that will be label's siblings.
        class Item(object):
            def __init__(self, label, submenu):
                self.label = label
                self.submenu = submenu

            def __cmp__(self, rhs):
                if self.submenu != rhs.submenu:
                    # self.submenu true comes before self.submenu false.
                    return cmp(not self.submenu, not rhs.submenu)
                if self.label != rhs.label:
                    return cmp(self.label, rhs.label)
                return 0

        submenu_items = pm.menu(parent, q=True, ia=True)
        sibling_labels = []
        for item in submenu_items:
            # Ignore options boxes.
            if pm.menuItem(item, q=True, optionBox=True):
                continue

            label = Item(item, pm.menuItem(item, q=True, subMenu=True))
            sibling_labels.append(label)

        item = Item(name, subMenu)
        insertion_point = bisect.bisect_left(sibling_labels, item)
        if insertion_point == 0:
            return None
        else:
            return sibling_labels[insertion_point - 1].label
Example #32
0
def _delete_login_menu():
    """
    Deletes the displayed Shotgun user login menu.
    """

    if pm.menu(MENU_LOGIN, exists=True):
        pm.deleteUI(MENU_LOGIN)
Example #33
0
def addmenu():
    global _menu
    global _menuItems
    with mayautils.undo_on_error():
        _menu = pmc.menu('HDR Interpolation', parent=mayautils.get_main_window_name())
        item = pmc.menuItem(parent=_menu, label='Show Menu', command=show)
        _menuItems.append(item)
Example #34
0
    def build_menu(self):
        """ build spore main menu """

        self.logger.debug('Build menu...')
        main_wnd = pm.language.melGlobals['gMainWindow']
        menu = pm.menu('Spore', parent=main_wnd)
        pm.menuItem(
            l='Spore Manager',
            c='import sys;sys._global_spore_dispatcher.spore_manager.show()',
            parent=menu)
        pm.menuItem(divider=True)
        pm.menuItem(l='Create Spore', c='cmds.spore()', parent=menu)
        pm.menuItem(divider=True)
        pm.menuItem(
            l='Spore Globals',
            c='import sys;sys._global_spore_dispatcher.spore_globals.show()',
            parent=menu)
        pm.menuItem(
            l='Spore Reporter',
            c='import sys;sys._global_spore_dispatcher.spore_reporter.show()',
            parent=menu)
        pm.menuItem(l='Help', c='print help', parent=menu)

        if os.environ.get('SPORE_DEV_MODE', '0') == '1':
            pm.menuItem(l='Run tests',
                        c='import test_util;test_util.run_tests_from_maya',
                        parent=menu)

        return menu
Example #35
0
def MakeMenu(menuTitle):
    """
    Creates & returns a new menu instance.
    
    :param menuTitle: string, title for the menu.
    """
    return pm.menu(menuTitle)
Example #36
0
def refresh_engine(engine_name, prev_context, menu_name):
    """
    refresh the current engine
    """
    current_engine = tank.platform.current_engine()

    # first make sure that the disabled menu is reset, if it exists...
    if pm.menu("ShotgunMenuDisabled", exists=True):
        pm.deleteUI("ShotgunMenuDisabled")

    # if the scene opened is actually a file->new, then maintain the current
    # context/engine.
    if pm.sceneName() == "":
        return current_engine

    new_path = pm.sceneName().abspath()

    # this file could be in another project altogether, so create a new Tank
    # API instance.
    try:
        tk = tank.tank_from_path(new_path)
    except tank.TankError, e:
        OpenMaya.MGlobal.displayInfo("Shotgun: Engine cannot be started: %s" %
                                     e)
        # render menu
        create_tank_disabled_menu(menu_name)

        # (AD) - this leaves the engine running - is this correct?
        return current_engine
Example #37
0
def _delete_login_menu():
    """
    Deletes the displayed Shotgun user login menu.
    """

    if pm.menu(MENU_LOGIN, exists=True):
        pm.deleteUI(MENU_LOGIN)
Example #38
0
def _create_login_menu():
    """
    Creates and displays a Shotgun user login menu.
    """

    # Creates the menu entry in the application menu bar.
    menu = pm.menu(MENU_LOGIN, label=MENU_LABEL, parent=pm.melGlobals["gMainWindow"])

    # Add the login menu item.
    pm.menuItem(
        parent=menu,
        label="Log In to Shotgun...",
        command=pm.Callback(_login_user)
    )

    pm.menuItem(parent=menu, divider=True)

    # Add the website menu items.
    pm.menuItem(
        parent=menu,
        label="Learn about Shotgun...",
        command=pm.Callback(_jump_to_website)
    )
    pm.menuItem(
        parent=menu,
        label="Try Shotgun for Free...",
        command=pm.Callback(_jump_to_signup)
    )
Example #39
0
def refresh_engine(engine_name, prev_context, menu_name):
    """
    refresh the current engine
    """    
    current_engine = tank.platform.current_engine()
    
    # first make sure that the disabled menu is reset, if it exists...
    if pm.menu("ShotgunMenuDisabled", exists=True):
        pm.deleteUI("ShotgunMenuDisabled")
    
    # if the scene opened is actually a file->new, then maintain the current
    # context/engine.
    if pm.sceneName() == "":
        return current_engine

    new_path = pm.sceneName().abspath()
    
    # this file could be in another project altogether, so create a new Tank
    # API instance.
    try:
        tk = tank.tank_from_path(new_path)
    except tank.TankError, e:
        OpenMaya.MGlobal.displayInfo("Shotgun: Engine cannot be started: %s" % e)
        # render menu
        create_tank_disabled_menu(menu_name)
        
        # (AD) - this leaves the engine running - is this correct?        
        return current_engine
Example #40
0
def _create_login_menu():
    """
    Creates and displays a Shotgun user login menu.
    """

    # Creates the menu entry in the application menu bar.
    menu = pm.menu(MENU_LOGIN, label=MENU_LABEL, parent=pm.melGlobals["gMainWindow"])

    # Add the login menu item.
    pm.menuItem(
        parent=menu,
        label="Log In to Shotgun...",
        command=pm.Callback(_login_user)
    )

    pm.menuItem(parent=menu, divider=True)

    # Add the website menu items.
    pm.menuItem(
        parent=menu,
        label="Learn about Shotgun...",
        command=pm.Callback(_jump_to_website)
    )
    pm.menuItem(
        parent=menu,
        label="Try Shotgun for Free...",
        command=pm.Callback(_jump_to_signup)
    )
Example #41
0
def loadMenu():
    #    get user menu from menu.xml
    menuXmlPath = digital37.path.path(__file__).parent.joinpath('menu.xml')

    #    get gMainWindow from mel command
    gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow')
    print gMainWindow
    if gMainWindow:

        if menuXmlPath.exists():
            menuLabel = ''
            menuName = 'digital37Menu'
            print('Build Menu : ' + menuName)

            #    open xml document
            menuXml = xml.dom.minidom.parse(menuXmlPath)

            #    search menu node
            for item in menuXml.getElementsByTagName('menu'):

                val = item.attributes["name"].value
                menuLabel = val.encode('latin-1', 'replace')

                #    search and delete old menuName
                menuList = pm.window(gMainWindow, query=True, menuArray=True)

                for menu in menuList:
                    if pm.menu(menu, query=True, label=True) == menuLabel:
                        pm.menu(menu, edit=True, deleteAllItems=True)
                        pm.deleteUI(menu)
                        break

                #    Add userMenu to Maya Menu
                pm.menu(menuName,
                        parent=gMainWindow,
                        tearOff=True,
                        label=menuLabel,
                        allowOptionBoxes=True)

                #    build each menu
                for child in item.childNodes:
                    if child.nodeType == 1:
                        #loadMenu_recursive(child)
                        nodename = child.nodeName
                        nodetype = child.attributes["type"].value

                        loadMenu_recursive(child, menuName)
Example #42
0
    def _add_menu_item_internal(self, name, insert_sorted=False, *args, **kwargs):
        if 'optionBox' in kwargs:
            # Maya creates an option box by adding it as a separate menu item.  We do it
            # by passing optionBox=function when creating the menu item itself, since it
            # makes things simpler.
            option_box = kwargs['optionBox']
            del kwargs['optionBox']
        else:
            option_box = None

        # We always need a label, even for dynamic menu names, so we can tell where to
        # put the menu item when insert_sorted is true.
        assert 'label' in kwargs

        # Don't create menu items in batch mode.  It causes a warning.
        if pm.about(batch=True):
            return

        # In case this menu item has already been created, remove the old one.
        _delete_menu_item(name)

        if insert_sorted:
            assert 'insertAfter' not in kwargs
            kwargs['insertAfter'] = self._get_sorted_insertion_point(name=name, subMenu=kwargs.get('subMenu', False), parent=kwargs.get('parent'))

            # If insertAfter is '' then the insertion point is the beginning.  However, Maya prints
            # an incorrect warning if you say insertAfter='' and there are no items in the submenu,
            # so remove it in this case.
            if not pm.menu(kwargs.get('parent'), q=True, ia=True):
                del kwargs['insertAfter']

        elif 'insertAfter' in kwargs and kwargs['insertAfter'] is None:
            # insertAfter=None causes the menu item to be added at the beginning.  We want
            # that to add at the end, so remove the argument.  This way, if a search for
            # a menu insertion point fails and returns None, we put things at the end (putting
            # them at the beginning is obnoxious).
            del kwargs['insertAfter']

        item = pm.menuItem(name, *args, **kwargs)

        # Add the option box, if any.
        if option_box is not None:
            option_box_name = name + 'Options'
            _delete_menu_item(option_box_name)

            # Maya option boxes are weird: they're regular menu items, and they appear over the
            # previous menu item, so we need to add if after the above menu item.
            item_name = item.split('|')[-1]
            name = pm.menuItem(optionBox=True, command=option_box, insertAfter=item_name, parent=kwargs['parent'])
            self.menu_items.add(name)

        # self.menu_items is a list of items that we need to remove.  Don't add submenus
        # to this list.  Rather than deleting them directly when we're unloaded, we leave
        # them alone and use the empty menu cleanup down below to remove them, so if two
        # plugins create the same submenu and one is unloaded, it doesn't remove the other
        # plugin's menu with it.
        if not kwargs.get('subMenu'):
            self.menu_items.add(item)
        return item
Example #43
0
 def create(self, *args, **kwargs):
   ''' '''
   if pm.control(self.windowName, exists = True):
     pm.deleteUI(self.windowName)
   if pm.control(self.dockName, exists = True):
     pm.deleteUI(self.dockName)
     
   if self.dockable:
     self.mainWindow = pm.window(self.windowName, t=self.windowName, menuBar=self.menuBar)
   else:
     self.mainWindow = pm.window(self.windowName, t=self.windowName, widthHeight=[self.width, self.height], menuBar=self.menuBar, rtf=self.rtf, mnb=self.mnb, mxb=self.mxb, s=self.sizeable)
   
   if self.menuBar:
     pm.menu(l='Help', helpMenu=True)
     pm.menuItem(l='blog.leocov.com', command=lambda *args: webbrowser.open('http://blog.leocov.com', new=2) )
     pm.menu(l='Tools')
     pm.menuItem(l='Make Shelf Icon', command=lambda *args: shelf.makeShelfButton(self.windowName, self.shelfCommand, self.icon, self.annotation) )
Example #44
0
def initialize():
    """
    This will setup the menu and interface mechanisms for the Crab Rigging
    Tool.

    :return: 
    """

    # -- If the menu already exists, we will delete it to allow
    # -- us to rebuild it
    if pm.menu(CRAB_MENU_OBJ, exists=True):
        pm.deleteUI(CRAB_MENU_OBJ)

    # -- Create the new menu for Crab
    new_menu = pm.menu(
        CRAB_MENU_OBJ,
        label=CRAB_MENU_NAME,
        tearOff=True,
        parent=pm.language.melGlobals['gMainWindow'],
    )

    add_menu_item('Creator', crab.creator.launch)
    add_menu_item('Animator', crab.animator.launch)

    pm.menuItem(divider=True, parent=new_menu)
    add_menu_item('Edit', _menu_edit_rig)
    add_menu_item('Build', _menu_build_rig)

    pm.menuItem(divider=True, parent=new_menu)
    add_menu_item('Website', _menu_goto_website)

    pm.menuItem(divider=True, parent=new_menu)
    add_menu_item('Reload', _menu_reload)

    # -- We specifically only want this menu to be visibile
    # -- in the rigging menu
    cached_menu_set = pm.menuSet(query=True, currentMenuSet=True)
    rigging_menu_set = pm.mel.findMenuSetFromLabel("Rigging")

    # -- Set our menu to the rigging menu and add it to
    # -- the menu set
    pm.menuSet(currentMenuSet=rigging_menu_set)
    pm.menuSet(addMenu=new_menu)

    # -- Restore the users cached menu set
    pm.menuSet(currentMenuSet=cached_menu_set)
Example #45
0
def create_sgtk_disabled_menu(menu_name):
    """
    Render a special "shotgun is disabled" menu
    """
    if cmds.about(batch=True):
        # don't create menu in batch mode
        return

    # destroy any pre-existing shotgun menu - the one that holds the apps
    if pm.menu("ShotgunMenu", exists=True):
        pm.deleteUI("ShotgunMenu")

    # create a new shotgun disabled menu if one doesn't exist already.
    if not pm.menu("ShotgunMenuDisabled", exists=True):
        sg_menu = pm.menu("ShotgunMenuDisabled", label=menu_name, parent=pm.melGlobals["gMainWindow"])
        pm.menuItem(label="Sgtk is disabled.", parent=sg_menu,
                    command=lambda arg: sgtk_disabled_message())
Example #46
0
    def update_shelf_submenu(parent_menu):
        """
        Populate a shelf submenu with the contents of a shelf.
        """
        shelf.refresh()

        # Gather the menu items, including submenus.
        pm.setParent(parent_menu, menu=True)
        menu_cmds = {}
        for shelf_button in shelf.buttons:
            if shelf_button is separator:
                continue
            menu_cmds[shelf_button] = get_menu_item_params(
                shelf_button, pm.shelfButton)

            popup_menu_items = get_shelf_submenus(shelf_button)
            for popup_menu_item in popup_menu_items:
                if popup_menu_item is separator:
                    continue
                menu_cmds[popup_menu_item] = get_menu_item_params(
                    popup_menu_item, pm.menuItem)

            # Store the list of popup menu item names as a dummy entry in menu_cmds.  This
            # won't be looked up by add_shelf_item.  This just makes sure that if the list of
            # popups changes, menu_cmds will be different from latest_menu_cmds and we'll refresh
            # the menu.
            menu_cmds['__popups_%s' % shelf_button] = popup_menu_items

        # If the menu hasn't changed since the last time it was displayed, don't update it.
        # Updating menus is usually fast, but sometimes becomes very slow for no obvious reason.
        if latest_menu_cmds == menu_cmds:
            return

        # Update latest_menu_cmds so we remember the latest update.
        latest_menu_cmds.clear()
        latest_menu_cmds.update(menu_cmds)

        # Clear the menu.
        pm.setParent(parent_menu, menu=True)
        pm.menu(parent_menu, e=True, deleteAllItems=True)

        for shelf_button in shelf.buttons:
            if shelf_button is separator:
                pm.menuItem(divider=True)
            else:
                add_shelf_item(parent_menu, menu_cmds, shelf_button)
Example #47
0
def create_sgtk_disabled_menu(menu_name):
    """
    Render a special "shotgun is disabled" menu
    """
    if cmds.about(batch=True):
        # don't create menu in batch mode
        return

    # destroy any pre-existing shotgun menu - the one that holds the apps
    if pm.menu("ShotgunMenu", exists=True):
        pm.deleteUI("ShotgunMenu")

    # create a new shotgun disabled menu if one doesn't exist already.
    if not pm.menu("ShotgunMenuDisabled", exists=True):
        sg_menu = pm.menu("ShotgunMenuDisabled", label=menu_name, parent=pm.melGlobals["gMainWindow"])
        pm.menuItem(label="Sgtk is disabled.", parent=sg_menu,
                    command=lambda arg: sgtk_disabled_message())
Example #48
0
    def create_material_submenu(self, parent, namespace):
        pm.setParent(parent, menu=True)
        pm.menu(parent, e=True, deleteAllItems=True)

        # Add namespaces at the top of the list.
        namespaces = self.namespaces_by_namespace.get(namespace, [])
        for child_namespace in namespaces:
            self.create_namespace_submenu(child_namespace)

        # Put a divider between namespaces and materials.
        materials = self.materials_by_namespace.get(namespace, [])
        if namespaces and materials:
            pm.menuItem(divider=True)

        # Add materials in this namespace.
        for material in materials:
            self.add_material_item(parent, material)
Example #49
0
def addmenu():
    global _menu
    global _menuItems
    with mayautils.undo_on_error():
        _menu = pmc.menu('HDR Interpolation',
                         parent=mayautils.get_main_window_name())
        item = pmc.menuItem(parent=_menu, label='Show Menu', command=show)
        _menuItems.append(item)
Example #50
0
 def destroy_engine(self):
     self.log_debug("%s: Destroying..." % self)
     
     # stop watching scene events:
     self.__watcher.stop_watching()
     
     # clean up UI:
     if self.has_ui and pm.menu(self._menu_handle, exists=True):
         pm.deleteUI(self._menu_handle)
Example #51
0
def loadMenu():
    #    get user menu from menu.xml
    menuXmlPath = digital37.path.path(__file__).parent.joinpath('menu.xml')
    
    
    #    get gMainWindow from mel command
    gMainWindow = pm.mel.eval('$tmpVar=$gMainWindow')
    print gMainWindow
    if gMainWindow:
        
        if menuXmlPath.exists() :        
            menuLabel = ''
            menuName    = 'digital37Menu'
            print ('Build Menu : ' + menuName)
    
            #    open xml document
            menuXml = xml.dom.minidom.parse(menuXmlPath)
            
            #    search menu node
            for item in menuXml.getElementsByTagName('menu'):
                
                val = item.attributes["name"].value
                menuLabel = val.encode('latin-1', 'replace')
    
                #    search and delete old menuName
                menuList = pm.window(gMainWindow, query=True, menuArray=True)
                
                for menu in menuList:
                    if pm.menu(menu, query=True, label=True) == menuLabel:
                        pm.menu(menu, edit=True, deleteAllItems=True)
                        pm.deleteUI(menu)
                        break
                
                #    Add userMenu to Maya Menu
                pm.menu(menuName, parent=gMainWindow, tearOff=True, label=menuLabel, allowOptionBoxes=True)
                
                #    build each menu
                for child in item.childNodes:
                        if child.nodeType == 1 :
                            #loadMenu_recursive(child)                     
                            nodename = child.nodeName
                            nodetype = child.attributes["type"].value
                            
                            loadMenu_recursive(child, menuName)
def make_test_items():
    menu = pmc.menu(
        'DemoMenu', parent=mayautils.get_main_window_name())
    def makeitem(ind):
        def callback(_):
            print 'Item', ind
        item = pmc.menuItem(
            parent=menu, label='Item %s' % ind, command=callback)
        register_menuitem(item.name())
    for i in range(5):
        makeitem(i)
Example #53
0
    def __init__(self):      
        # Name Autodesk gives to main Maya window  
        mainMayaWindow = pm.ui.PyUI("MayaWindow")

        # Check that it is actually created (just incase this is run before it)
        if type(mainMayaWindow) == pm.uitypes.Window:
            # Our menu 
            self.rootMenu = pm.menu("myMenu", parent=mainMayaWindow)
            self.rootMenu.setLabel("My Menu")
        else:
            pm.warning("WARNING! Maya main window is not initialized yet!")
            pm.warning("         Pipeline menu is not created")
Example #54
0
 def post_app_init(self):
     """
     Called when all apps have initialized
     """    
     # detect if in batch mode
     if self.has_ui:
         self._menu_handle = pm.menu("ShotgunMenu", label=self._menu_name, parent=pm.melGlobals["gMainWindow"])
         # create our menu handler
         tk_maya = self.import_module("tk_maya")
         self._menu_generator = tk_maya.MenuGenerator(self, self._menu_handle)
         # hook things up so that the menu is created every time it is clicked
         self._menu_handle.postMenuCommand(self._menu_generator.create_menu)
Example #55
0
    def create_shotgun_menu(self):
        """
        Creates the main shotgun menu in maya.
        Note that this only creates the menu, not the child actions
        :return: bool
        """

        # only create the shotgun menu if not in batch mode and menu doesn't already exist
        if self.has_ui and not pm.menu("ShotgunMenu", exists=True):

            self._menu_handle = pm.menu("ShotgunMenu", label=self._menu_name, parent=pm.melGlobals["gMainWindow"])
            # create our menu handler
            tk_maya = self.import_module("tk_maya")
            self._menu_generator = tk_maya.MenuGenerator(self, self._menu_handle)
            # hook things up so that the menu is created every time it is clicked
            self._menu_handle.postMenuCommand(self._menu_generator.create_menu)

            # Restore the persisted Shotgun app panels.
            tk_maya.panel_generation.restore_panels(self)
            return True

        return False
Example #56
0
def populateSelectCamera():
    # clear camera menu
    pm.menu('ArnoldSelectCamera', edit=True, deleteAllItems=True)

    coll = pm.radioMenuItemCollection(parent='ArnoldSelectCamera')

    # populate camera menu    
    cameras = cmds.ls(type='camera')
    if cameras != None:
        activeCamera = core.ACTIVE_CAMERA
        if not activeCamera in cameras:
            activeCamera = None
        if activeCamera == None:
            if 'perspShape' in cameras:
                activeCamera = 'perspShape'
            elif len(cameras):
                activeCamera = cameras[0]
            core.ACTIVE_CAMERA = activeCamera
        for cam in cameras:
            pm.menuItem('SelectCameraItem%s' % cam, label=cam, parent='ArnoldSelectCamera',
                        radioButton=cam == activeCamera, cl=coll,
                        c='from mtoa.ui.arnoldmenu import selectCamera; selectCamera("%s")' % cam)
Example #57
0
 def __init__(self, iconPath):
     self.name = "Control_Creation_UI"
     self.title = "Create Controls"
     
     if (pm.window(self.name, q=1, exists=1)): pm.deleteUI(self.name)
     self.window = pm.window(self.title, widthHeight=(300, 300),
                      resizeToFitChildren=1, menuBar=True)
     self.iconPath = iconPath
     icons = [f for f in os.listdir(self.iconPath) if f.endswith('.png')]
     
     #menu
     pm.menu( label='UI', helpMenu=True )
     pm.menuItem( label='Create Icons', command = pm.Callback(self.createIcons))
     
     form = pm.formLayout()
     tabs = pm.tabLayout(innerMarginWidth=5, innerMarginHeight=5)
     pm.formLayout( form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0)))
     
     child1 = pm.rowColumnLayout(numberOfColumns=3)
     for style in SimpleCurves.STYLES:
         if icons and "%s.png"%(style) in icons:
             iPath = os.path.join(self.iconPath, "%s.png"%(style))
             pm.iconTextButton(label=style, style='iconAndTextVertical', image1=iPath, command = pm.Callback(self.simpleCurve, style))
         else:
             pm.button(label=style, command = pm.Callback(self.simpleCurve, style))
     pm.setParent( '..' )
     
     child2 = pm.rowColumnLayout(numberOfColumns=2)
     pm.button()
     pm.setParent( '..' )
     
     child3 = pm.rowColumnLayout(numberOfColumns=2)
     pm.button()
     pm.button()
     pm.button()
     pm.setParent( '..' )
     
     pm.tabLayout( tabs, edit=True, tabLabel=((child1, 'Simple Curves'), (child2, 'Combo Controls'), (child3, 'Facial Controls')) )
     pm.showWindow(self.window)