Example #1
0
    def createInfluenceListRMBMenu(self):
        from ngSkinTools.ui.mainwindow import MainWindow
        actions = MainWindow.getInstance().actions

        self.controls.inflListMenu = cmds.popupMenu(
            parent=self.controls.influenceDisplay.control)
        actions.copyWeights.newMenuItem('Copy Influence Weights')
        actions.cutWeights.newMenuItem('Cut Influence Weights')
        actions.pasteWeightsAdd.newMenuItem('Paste Weights (Add)')
        actions.pasteWeightsReplace.newMenuItem('Paste Weights (Replace)')
        cmds.menuItem(divider=True)

        cmds.radioMenuItemCollection()
        self.controls.menuAllInfluences = cmds.menuItem(
            label='List All Influences',
            enable=True,
            radioButton=True,
            command=self.influenceMenuChangeCommand)
        self.controls.menuActiveInfluences = cmds.menuItem(
            label='List Only Active Influences',
            enable=True,
            radioButton=False,
            command=self.influenceMenuChangeCommand)

        cmds.menuItem(divider=True)

        actions.convertMaskToTransparency.newMenuItem(
            'Convert Mask to Transparency')
        actions.convertTransparencyToMask.newMenuItem(
            'Convert Transparency to Mask')

        cmds.menuItem(divider=True)

        actions.influenceFilter.newMenuItem('Show/Hide Influence Filter')
Example #2
0
    def populateMenu(self, menu, *args):

        cmds.radioMenuItemCollection(parent=menu)
        for loopOption in self.multiplierValues:
            radioSelected   = (self.multiplier == loopOption["value"])
            option          = loopOption["name"]
            cmds.menuItem (label=utilMod.toTitle(loopOption["name"]), radioButton=radioSelected, command=lambda x, option=option, *args: self.setMultiplier(option),  parent=menu)
	def setupCtrlEnv(self):
		# Loop through all the controls
		for i, row in self.charSel.rows.items():
			for m, ctrl in enumerate( row ):
				if( type(ctrl) != list):
					if( ctrl.ctrlType == "ctrl" or ctrl.ctrlType == "chk" ):
						# self.ctrls[self.charSel.rows[i][m]] = "It's a control"   # Temp for setting up the control
						self.ctrls[ctrl.fileName] = [[], None]
						ctrl.setCommand( Callback(self.ctrlSystem, ctrl.fileName ) )
						pop = cmds.popupMenu( parent=ctrl.gui )
						rbCol = cmds.radioMenuItemCollection( parent=pop)
						cmds.menuItem(label="Rotate", cl=rbCol, rb=False, c=Callback( self._setSwitch, ctrl.fileName, "rotate" ))
						cmds.menuItem(label="Translate", cl=rbCol, rb=False, c=Callback( self._setSwitch, ctrl.fileName, "trans" ))
						cmds.menuItem( divider=True )
						cmds.menuItem(label="None", cl=rbCol, rb=True, c=Callback( self._setSwitch, ctrl.fileName, None ))
				elif( type(ctrl) == list):	
					for subCol in range( 0, len(ctrl)):
						if(ctrl[subCol].ctrlType == "ctrl" or ctrl[subCol].ctrlType == "chk" ):
							self.ctrls[ctrl[subCol].fileName] = [[], None]
							ctrl[subCol].setCommand( Callback(self.ctrlSystem, ctrl[subCol].fileName ) )
							pop = cmds.popupMenu( parent=ctrl[subCol].gui )
							rbCol = cmds.radioMenuItemCollection( parent=pop)
							cmds.menuItem(label="Rotate", cl=rbCol, rb=False, c=Callback( self._setSwitch, ctrl[subCol].fileName, "rotate" ))
							cmds.menuItem(label="Translate", cl=rbCol, rb=False, c=Callback( self._setSwitch, ctrl[subCol].fileName, "trans" ))
							cmds.menuItem( divider=True )
							cmds.menuItem(label="None", cl=rbCol, rb=True, c=Callback( self._setSwitch, ctrl[subCol].fileName, None ))							
Example #4
0
    def createInfluenceListRMBMenu(self):
        from ngSkinTools.ui.mainwindow import MainWindow
        actions = MainWindow.getInstance().actions
        
        self.controls.inflListMenu = cmds.popupMenu( parent=self.controls.influenceDisplay.control )
        actions.copyWeights.newMenuItem('Copy Influence Weights')
        actions.cutWeights.newMenuItem('Cut Influence Weights')
        actions.pasteWeightsAdd.newMenuItem('Paste Weights (Add)')
        actions.pasteWeightsReplace.newMenuItem('Paste Weights (Replace)')
        cmds.menuItem( divider=True)
        
        
        cmds.radioMenuItemCollection()
        self.controls.menuAllInfluences = cmds.menuItem(label='List All Influences',
                enable=True, radioButton=True,command=self.influenceMenuChangeCommand )
        self.controls.menuActiveInfluences = cmds.menuItem(label='List Only Active Influences',
                enable=True, 
                radioButton=False,command=self.influenceMenuChangeCommand )
        
        cmds.menuItem( divider=True)
        
        actions.convertMaskToTransparency.newMenuItem('Convert Mask to Transparency')
        actions.convertTransparencyToMask.newMenuItem('Convert Transparency to Mask')

        cmds.menuItem( divider=True)
        
        actions.influenceFilter.newMenuItem('Show/Hide Influence Filter')
Example #5
0
def build(parent, imagesPath, iconSize=25, height=20, marginSize=5):
    """
      build widget
      @param parent : parent layout in maya
      @imagesPath : str path
      """
    cmds.rowLayout(numberOfColumns=1, parent=parent)
    cmds.iconTextButton(style='iconOnly',
                        image1=os.path.join(imagesPath, 'decalcomanie.png'),
                        hi=os.path.join(imagesPath, 'decalcomanie_hi.png'),
                        width=iconSize * 1.2,
                        mw=marginSize,
                        height=iconSize,
                        mh=marginSize,
                        label='decalcomanie',
                        annotation='Copy Left or Right anim to Right or Left',
                        c=runDecalComanie)
    cmds.popupMenu()
    cmds.radioMenuItemCollection()
    UIContainer.radioMenuItemDCNModePose = cmds.menuItem(
        label='Mirror Pose of Current Frame',
        radioButton=True,
        c=partial(writeDCNMode, 'pose'))
    UIContainer.radioMenuItemDCNModeAnim = cmds.menuItem(
        label='Mirror Animation',
        radioButton=False,
        c=partial(writeDCNMode, 'anim'))
    cmds.setParent("..")
    readDCNMode()
Example #6
0
 def populateMenu(self, menu, *args):
     uiMod.clearMenuItems(menu)
     uiMod.clearMenuItems(menu)
     #cmds.menuItem(label="Clear motion trails", command=self.clear)
     cmds.radioMenuItemCollection(parent=menu)
     
     currRange    = [cmds.playbackOptions(query=True, minTime=True), cmds.playbackOptions(query=True, maxTime=True)]
     currRangeStr = "%s   -   %s"%(int(currRange[0]), int(currRange[1]))            
      
     #populate list
     ranges = self.getTimelineRanges()
     if ranges: ranges   = eval(ranges)
     if ranges:
         for loopRange in ranges:
             loopRangeStr    = "%s   -   %s"%(int(loopRange[0]), int(loopRange[1]-1))                                
             radioButton     = (currRangeStr == loopRangeStr)
             cmds.menuItem("menu_%s"%loopRange, radioButton=radioButton, label=loopRangeStr, parent=menu, command=lambda x, loopRange=loopRange, *args: self.setTimelineRange(loopRange))
         cmds.menuItem( divider=True, parent=menu)   
         newMenu = cmds.menuItem(subMenu=True, label='Delete', parent=menu) 
         cmds.menuItem( divider=True, parent=menu)  
         for loopRange in ranges:
             loopRangeStr = "%s   -   %s"%(int(loopRange[0]), int(loopRange[1]-1))
             cmds.menuItem("menu_%s"%loopRange, label=loopRangeStr, parent=newMenu, command=lambda x, loopRange=loopRange, *args: self.deleteTimelineRange(loopRange))
         cmds.menuItem( divider=True, parent=newMenu)       
         cmds.menuItem("menu_deleteAll", label="Delete All", parent=newMenu, command=self.deleteAllTimelineRange)
     cmds.menuItem("toggleLipSyncModeMenu", label='Lip Sync Mode', checkBox=self.isLipSyncMode(), command=self.toggleLipSyncMode, parent=menu) 
Example #7
0
def build(parent,
          imagesPath,
          iconSize=25,
          height=20,
          marginSize=5):
    """
    build widget
    @param parent : parent layout in maya
    @imagesPath : str path
    """
    # - Copy Paste Animation--------------------------------------------------
    cmds.rowLayout(numberOfColumns=2)
    cmds.iconTextButton(style='iconOnly',
                        image1=os.path.join(imagesPath, 'copy.png'),
                        hi=os.path.join(imagesPath, 'copy_hi.png'),
                        width=iconSize, mw=marginSize, height=iconSize, mh=marginSize,
                        label='cv',
                        npm=1,
                        annotation='copy current animation or pose. Right click for reset tool. Preserves current session',
                        c=copySession)
    cmds.popupMenu()
    cmds.radioMenuItemCollection()
    UIContainer.radioMenuItemACSModePose = cmds.menuItem(label='Copy Pose of Current Frame',
                                                         radioButton=True,
                                                         c=partial(writeACSMode, 'pose'))
    UIContainer.radioMenuItemACSModeAnim = cmds.menuItem(label='Copy Animation',
                                                         radioButton=False,
                                                         c=partial(writeACSMode, 'anim'))
    cmds.menuItem(divider=True)
    cmds.menuItem(label="Reset", command=copyReset)
    cmds.setParent("..")

    readACSMode()
 def _make_opt_menu(self, *args):
     """
     Make the options menu
     """
     clear_menu(self._opt_menu)
     show_menu = mc.menuItem(p=self._opt_menu,
                             label="Show...",
                             subMenu=True)
     # Menu bar  and label visibility toggles
     if SETTINGS["ui_mode"] in ["window", "dock"]:
         mc.menuItem(p=show_menu,
                     label="Menu Bar",
                     cb=SETTINGS["show_menu_bar"],
                     command=self._toggle_menu_visibility)
     mc.menuItem(p=show_menu,
                 label="Label",
                 cb=SETTINGS["show_label"],
                 command=self._toggle_label_visibility)
     mc.menuItem(p=show_menu, divider=True)
     # Slider and button visibility options
     show_collection = mc.radioMenuItemCollection(parent=show_menu)
     mc.menuItem(p=show_menu,
                 label="Slider and Buttons",
                 rb=self.show_mode == "both",
                 command=lambda x, m="both": self._set_show_mode(m))
     mc.menuItem(p=show_menu,
                 label="Slider Only",
                 rb=self.show_mode == "slider",
                 command=lambda x, m="slider": self._set_show_mode(m))
     mc.menuItem(p=show_menu,
                 label="Buttons Only",
                 rb=self.show_mode == "buttons",
                 command=lambda x, m="buttons": self._set_show_mode(m))
     # UI mode options
     if "2013" not in MAYA_VERSION:
         mc.menuItem(p=self._opt_menu, divider=True)
         mode_menu = mc.menuItem(p=self._opt_menu,
                                 label="Mode...",
                                 subMenu=True)
         mode_collection = mc.radioMenuItemCollection(parent=mode_menu)
         mc.menuItem(p=mode_menu,
                     label="Window",
                     rb=SETTINGS["ui_mode"] == "window",
                     command=lambda x, m="window": self.set_ui_mode(m))
         mc.menuItem(p=mode_menu,
                     label="Toolbar",
                     rb=SETTINGS["ui_mode"] == "toolbar",
                     command=lambda x, m="toolbar": self.set_ui_mode(m))
     #       mc.menuItem(p=mode_menu, label="HUD",
     #                    rb=SETTINGS["ui_mode"] == "hud",
     #                    command=lambda x, m="hud":self.set_ui_mode(m))
     mc.menuItem(p=self._opt_menu, divider=True)
     mc.menuItem(p=self._opt_menu,
                 label="Overshoot",
                 cb=self.use_overshoot,
                 command=self._toggle_overshoot)
     mc.menuItem(p=self._opt_menu,
                 label="Special Tick Color",
                 cb=self.use_special_tick,
                 command=self._toggle_special_tick)
def show(*args, **kwargs):
    cmds.menuItem(label='Filter', divider=True)
    cmds.radioMenuItemCollection()
    cmds.menuItem(label='All',
                  command=partial(set_curve_filter, Outliner_Filter.all))
    cmds.menuItem(label='Translate Rotate',
                  command=partial(set_curve_filter,
                                  Outliner_Filter.translate_rotate))
    cmds.menuItem(label='User', command=partial(set_curve_filter, 'user'))

    cmds.menuItem(label='Infinity', divider=True)
    cmds.menuItem(label='Constant',
                  command=partial(set_curve_infinity, Infinity_Type.constant))
    cmds.menuItem(label='Linear',
                  command=partial(set_curve_infinity, Infinity_Type.lienar))
    cmds.menuItem(label='Cycle',
                  command=partial(set_curve_infinity, Infinity_Type.cycle))
    cmds.menuItem(label='Offset',
                  command=partial(set_curve_infinity, Infinity_Type.offset))

    cmds.menuItem(label='Keys', divider=True)
    cmds.menuItem(l='Delete Redundant', c=keys.deleteRedundant)
    cmds.menuItem(l='Delete Static Channels', c=keys.deleteStaticAllChannels)

    cmds.menuItem(label='Noise', divider=True)
    # cmds.menuItem(label='Add Noise', command=test_callback)
    cmds.menuItem(label='Smooth', command=animFilters.main)
    return
Example #10
0
    def populateSelSetButtonsMenu(self, menu, selSet, *args):
        
        extracted   = self.extractInfoFromSelSet(selSet)
        colorName   = extracted["colorName"]

        cmds.radioMenuItemCollection(parent=menu)
        
        for loopColor in self.colors:
            loopColorName  = loopColor["name"]
            radioSelected = (colorName == loopColorName)
            cmds.menuItem(label=utilMod.toTitle(loopColorName),   radioButton=radioSelected,        command=lambda x, selSet=selSet, loopColorName=loopColorName, *args: self.renameSelectSetColor([selSet], loopColorName),  parent=menu)
            
         
        cmds.menuItem(divider=True,  parent=menu)
        cmds.menuItem(label='Add Selection',    command=lambda *args: self.addSelection(selSet),  parent=menu)
        cmds.menuItem(label='Remove Selection', command=lambda *args: self.removeSelection(selSet),  parent=menu)
        cmds.menuItem(label='Update Selection', command=lambda *args: self.updateSelection(selSet),  parent=menu)
        cmds.menuItem(divider=True,  parent=menu)
        cmds.menuItem(label='Rename',           command=lambda *args: self.turnOnRenameSetField(selSet),  parent=menu)
        cmds.menuItem(label='Delete',           command=lambda *args: self.deleteSets([selSet]),  parent=menu)
        cmds.menuItem(label='Delete All %s'%utilMod.toTitle(colorName),    command=lambda *args: self.deleteAllColorSet(colorName),  parent=menu)
        cmds.menuItem(divider=True,  parent=menu)
        
        duplicateToOtherMenu = cmds.menuItem(subMenu=True, label='Duplicate To Other Character', parent=menu, postMenuCommandOnce=True)
        cmds.menuItem(duplicateToOtherMenu, edit=True,  postMenuCommand=lambda *args:self.populateDuplicateToOtherMenu(duplicateToOtherMenu, selSet))
        cmds.setParent( '..', menu=True ) 
               
        
        cmds.menuItem(label='Show Only %s'%utilMod.toTitle(colorName),  command=lambda *args: self.isolateColor(colorName),  parent=menu)
        cmds.menuItem(label='Hide %s'%utilMod.toTitle(colorName),       command=lambda *args: self.hideColor(colorName),  parent=menu)
Example #11
0
def populateItems(subMenu, items):
    """
	Populates the given submenu with the specified items. subMenu
	is a string identifier of the sub menu and items is a list of
	stereoCameraUILabel entries.
	"""
    cmds.setParent(subMenu, menu=True)

    for i in items:
        if i and i.type() == stereoCameraUILabel.UILabelGroup:
            parent = subMenu
            if not i.radioGroup():
                parent = cmds.menuItem(label=i.label(), subMenu=True)
            else:
                cmds.radioMenuItemCollection()
            if i.postMenuCommand():
                i.setArgs([parent])
                cmds.menuItem(parent, edit=True, postMenuCommand=i.command())
                cmds.setParent('..', menu=True)
            else:
                populateItems(parent, i.items())
        else:
            if not i or not i.label():
                if not i.divider_label():
                    cmds.menuItem(divider=True)
                else:
                    cmds.menuItem(divider=True, dividerLabel=i.divider_label())
            else:
                radiogrp = i.radioGrpItem()
                item = None
                if radiogrp:
                    radioval = i.radioItemOn()
                    cmds.menuItem(label=i.label(),
                                  annotation=i.annotation(),
                                  image=i.image(),
                                  command=i.command(),
                                  radioButton=radioval,
                                  enable=(i.enabled()))
                elif i.check_box() != "":
                    callbackMethod = i.check_box()
                    cmds.menuItem(label=i.label(),
                                  annotation=i.annotation(),
                                  command=i.command(),
                                  checkBox=callbackMethod())
                else:
                    cmds.menuItem(label=i.label(),
                                  annotation=i.annotation(),
                                  image=i.image(),
                                  command=i.command(),
                                  enable=(i.enabled()))

                if i.option_box():
                    cmds.menuItem(label=i.label() + 'Option',
                                  annotation=i.annotation() + ' Options',
                                  command=i.command_option(),
                                  optionBox=True)

    cmds.setParent('..', menu=True)
Example #12
0
    def populateSelSetButtonsMenu(self, menu, selSet, *args):

        extracted = self.extractInfoFromSelSet(selSet)
        colorName = extracted["colorName"]

        cmds.radioMenuItemCollection(parent=menu)

        for loopColor in self.colors:
            loopColorName = loopColor["name"]
            radioSelected = (colorName == loopColorName)
            cmds.menuItem(
                label=utilMod.toTitle(loopColorName),
                radioButton=radioSelected,
                command=lambda x, selSet=selSet, loopColorName=loopColorName, *
                args: self.renameSelectSetColor([selSet], loopColorName),
                parent=menu)

        cmds.menuItem(divider=True, parent=menu)
        cmds.menuItem(label='Add Selection',
                      command=lambda *args: self.addSelection(selSet),
                      parent=menu)
        cmds.menuItem(label='Remove Selection',
                      command=lambda *args: self.removeSelection(selSet),
                      parent=menu)
        cmds.menuItem(label='Update Selection',
                      command=lambda *args: self.updateSelection(selSet),
                      parent=menu)
        cmds.menuItem(divider=True, parent=menu)
        cmds.menuItem(label='Rename',
                      command=lambda *args: self.turnOnRenameSetField(selSet),
                      parent=menu)
        cmds.menuItem(label='Delete',
                      command=lambda *args: self.deleteSets([selSet]),
                      parent=menu)
        cmds.menuItem(label='Delete All %s' % utilMod.toTitle(colorName),
                      command=lambda *args: self.deleteAllColorSet(colorName),
                      parent=menu)
        cmds.menuItem(divider=True, parent=menu)

        duplicateToOtherMenu = cmds.menuItem(
            subMenu=True,
            label='Duplicate To Other Character',
            parent=menu,
            postMenuCommandOnce=True)
        cmds.menuItem(
            duplicateToOtherMenu,
            edit=True,
            postMenuCommand=lambda *args: self.populateDuplicateToOtherMenu(
                duplicateToOtherMenu, selSet))
        cmds.setParent('..', menu=True)

        cmds.menuItem(label='Show Only %s' % utilMod.toTitle(colorName),
                      command=lambda *args: self.isolateColor(colorName),
                      parent=menu)
        cmds.menuItem(label='Hide %s' % utilMod.toTitle(colorName),
                      command=lambda *args: self.hideColor(colorName),
                      parent=menu)
Example #13
0
 def setupCtrlEnv(self):
     # Loop through all the controls
     for i, row in self.charSel.rows.items():
         for m, ctrl in enumerate(row):
             if (type(ctrl) != list):
                 if (ctrl.ctrlType == "ctrl" or ctrl.ctrlType == "chk"):
                     # self.ctrls[self.charSel.rows[i][m]] = "It's a control"   # Temp for setting up the control
                     self.ctrls[ctrl.fileName] = [[], None]
                     ctrl.setCommand(
                         Callback(self.ctrlSystem, ctrl.fileName))
                     pop = cmds.popupMenu(parent=ctrl.gui)
                     rbCol = cmds.radioMenuItemCollection(parent=pop)
                     cmds.menuItem(label="Rotate",
                                   cl=rbCol,
                                   rb=False,
                                   c=Callback(self._setSwitch,
                                              ctrl.fileName, "rotate"))
                     cmds.menuItem(label="Translate",
                                   cl=rbCol,
                                   rb=False,
                                   c=Callback(self._setSwitch,
                                              ctrl.fileName, "trans"))
                     cmds.menuItem(divider=True)
                     cmds.menuItem(label="None",
                                   cl=rbCol,
                                   rb=True,
                                   c=Callback(self._setSwitch,
                                              ctrl.fileName, None))
             elif (type(ctrl) == list):
                 for subCol in range(0, len(ctrl)):
                     if (ctrl[subCol].ctrlType == "ctrl"
                             or ctrl[subCol].ctrlType == "chk"):
                         self.ctrls[ctrl[subCol].fileName] = [[], None]
                         ctrl[subCol].setCommand(
                             Callback(self.ctrlSystem,
                                      ctrl[subCol].fileName))
                         pop = cmds.popupMenu(parent=ctrl[subCol].gui)
                         rbCol = cmds.radioMenuItemCollection(parent=pop)
                         cmds.menuItem(label="Rotate",
                                       cl=rbCol,
                                       rb=False,
                                       c=Callback(self._setSwitch,
                                                  ctrl[subCol].fileName,
                                                  "rotate"))
                         cmds.menuItem(label="Translate",
                                       cl=rbCol,
                                       rb=False,
                                       c=Callback(self._setSwitch,
                                                  ctrl[subCol].fileName,
                                                  "trans"))
                         cmds.menuItem(divider=True)
                         cmds.menuItem(label="None",
                                       cl=rbCol,
                                       rb=True,
                                       c=Callback(self._setSwitch,
                                                  ctrl[subCol].fileName,
                                                  None))
Example #14
0
def gridMenu(*args, **kwargs):
	ui = cmds.menu(l='Grid')
	cmds.menuItem(label='Visible', checkBox=True, command=toggle_grid)
	cmds.menuItem(d=True)
	cmds.radioMenuItemCollection()
	cmds.menuItem(label='Centimeters', radioButton=True, command=partial(edit_grid, 'centimeters'))
	cmds.menuItem(label='Meters', radioButton=False, command=partial(edit_grid, 'meters'))
	cmds.menuItem(label='Inches', radioButton=False, command=partial(edit_grid, 'inches'))
	cmds.menuItem(label='Feet', radioButton=False, command=partial(edit_grid, 'feet'))
	return ui
Example #15
0
    def populateMenu(self, menu, *args):

        cmds.radioMenuItemCollection(parent=menu)
        for loopOption in self.multiplierValues:
            radioSelected = (self.multiplier == loopOption["value"])
            option = loopOption["name"]
            cmds.menuItem(label=utilMod.toTitle(loopOption["name"]),
                          radioButton=radioSelected,
                          command=lambda x, option=option, *args: self.
                          setMultiplier(option),
                          parent=menu)
Example #16
0
    def createInflListContextMenu(self):
        list = self.controls.inflList
        self.controls.inflListMenu = cmds.popupMenu( parent=list )
        self.controls.menuPinInfluence = cmds.menuItem(label='Pin Influence',enable=False)
        self.controls.menuPaintWeights = cmds.menuItem(label='Paint Weights',enable=False,command=self.doInflListPaintWeights)

        cmds.menuItem( divider=True )
        cmds.radioMenuItemCollection()
        self.controls.menuNoLockFilter = cmds.menuItem( label='Show Both Locked and Unlocked Influences', radioButton=True )
        self.controls.menuHideLocked = cmds.menuItem( label='Hide Locked Influences', radioButton=False )
        self.controls.menuHideUnlocked = cmds.menuItem( label='Hide Unlocked Influences', radioButton=False )
Example #17
0
def MenuBar():
    _menuBarLayout = cmds.menuBarLayout()

    cmds.menu( label='Options' )
    cmds.menuItem( label='Switch Window, Dock', c= SwitchUI)

    cmds.menuItem( divider=True ) #-----------------------------------------------------------------------------------------------

    cmds.menuItem( label='Reload Script', c= reloadScript)
    cmds.menuItem( label='Script Debug', checkBox=_debug, c= setDebug)

    cmds.menuItem( divider=True ) #-----------------------------------------------------------------------------------------------

    cmds.menuItem( label='Set to Default',      c= setToDefault)
    
    cmds.menuItem( subMenu=True, label='Update Mode' )
    cmds.radioMenuItemCollection()
    cmds.menuItem( label='Update by selection',            radioButton= _updateMode==1, c= pyMel.Callback(UI_RBG_updateMode,1) )
    cmds.menuItem( label='Remind the last selection data', radioButton= _updateMode==2, c= pyMel.Callback(UI_RBG_updateMode,2))
    cmds.setParent( '..', menu=True )

    cmds.menuItem( subMenu=True, label='scriptJob' )
    cmds.menuItem( label='Add scriptJob', c=addScriptJob)
    cmds.menuItem( label='Remove scriptJob', c=removeScriptJob)
    cmds.setParent( '..', menu=True )

    cmds.menuItem( divider=True ) #-----------------------------------------------------------------------------------------------  

    cmds.menuItem( label='Print Current Data', c= btnCmd_printCurrentState)


    '''
    cmds.menuItem( subMenu=True, label='Colors' )
    cmds.menuItem( label='Blue' )
    cmds.menuItem( label='Green' )
    cmds.menuItem( label='Yellow' )
    cmds.setParent( '..', menu=True )
    cmds.menuItem( divider=True )

    cmds.radioMenuItemCollection()
    cmds.menuItem( label='Yes', radioButton=False )
    cmds.menuItem( label='Maybe', radioButton=False )
    cmds.menuItem( label='No', radioButton=True )
    cmds.menuItem( divider=True )
    cmds.menuItem( label='Top', checkBox=True )
    cmds.menuItem( label='Middle', checkBox=False )
    cmds.menuItem( label='Bottom', checkBox=True )
    cmds.menuItem( divider=True )
    cmds.menuItem( label='Option' )
    cmds.menuItem( optionBox=True )
    '''
    cmds.menu( label='Help' )
Example #18
0
	def __init__(self):
		self.evaluation = cmds.evaluationManager(q=True, mode=True)[0]
		self.tearOffScriptJob = None
		self.timelineScriptJob = None

		self.ui = cmds.menuBarLayout()

		cmds.menu(l='Scene')
		cmds.menuItem(d=True, dl='On New Scene')
		cmds.menuItem(l='Tear Off Copy', cb=True, c=self.tearOffCallback)
		cmds.menuItem(l='Set Timeline (1001-1200)', cb=True, c=self.timelineCallback)
		# cmds.menuItem(l='Playback: Every Frame', cb=True)

		cmds.menu(l='Evaluation')
		cmds.radioMenuItemCollection()
		cmds.menuItem(l='DG', rb=False, c=lambda *_: self.evalCallback(Component.dg), enable=False)
		cmds.menuItem(l='Serial', rb=False, c=lambda *_: self.evalCallback(Component.serial), enable=False)
		cmds.menuItem(l='Parallel', rb=True, c=lambda *_: self.evalCallback(Component.parallel))
		cmds.menuItem(d=True)
		cmds.menuItem(l='Print Debug Info', c=self.debugEvaluation)

		cmds.menu(l='Keys')
		cmds.menuItem(l='Delete Redundant', c=anim_mancer.tools.keys.deleteRedundant)
		cmds.menuItem(l='Delete All Static Channels', c=anim_mancer.tools.keys.deleteStaticAllChannels)

		cmds.menu(l='Tangents')
		prefsRadioMenu(pref='default tangent', )
		cmds.menuItem(l='', divider=True)
		cmds.menuItem(l='Weighted tangents', checkBox=(cmds.keyTangent(q=True, g=True, wt=True)),
					  c=lambda x: cmds.keyTangent(e=True, g=True, wt=x))

		cmds.menu(l='Time')
		prefsRadioMenu(pref='playback speed', )
		cmds.menuItem(d=True)
		cmds.menuItem(l='Snapping', cb=mel.eval('timeControl -q -snap $gPlayBackSlider;'), c=self.timeSnapCallback)

		gridMenu()

		cmds.menu(l='UI', hm=True)
		cmds.menuItem(l='Close', c=removeUI)
		cmds.setParent('..')

		# ScriptJobs
		cmds.scriptJob(p=self.ui, event=['SceneOpened', self.setDefaults])

		# Defaults
		self.setDefaults()
		# self.createTearOffScriptJob()
		self.createTimelineScriptJob()
		set_timeline()
		savePrefs()
Example #19
0
    def prefsRadioMenu(self, pref, *args):

        if pref:

            # Get pref type

            if pref == 'evaluation':
                list = ['off', 'serial', 'parallel']
                current = cmds.evaluationManager(q=True, mode=True)[0]

            elif pref == 'default tangent':
                list = ['auto', 'clamped', 'linear', 'spline']
                current = cmds.keyTangent(q=True, g=True, itt=True)[0]

            elif pref == 'frames per second':
                list = ['film', 'ntsc', 'ntscf']
                current = cmds.currentUnit(q=True, t=True)

            elif pref == 'playback speed':
                list = [0.0, 1.0]
                current = cmds.playbackOptions(q=True, ps=True)

            elif pref == 'up axis':
                list = ['y', 'z']
                current = cmds.upAxis(q=True, ax=True)

            elif pref == 'working units':
                list = ['mm', 'cm', 'm']
                current = cmds.currentUnit(q=True, l=True)

            # Build Menu

            # Divider

            cmds.menuItem(l=pref.capitalize(), divider=True)
            cmds.radioMenuItemCollection()

            # Radio Buttons

            for obj in list:

                if obj == current:
                    currentVar = True

                else:
                    currentVar = False

                item = cmds.menuItem(label=str(obj).capitalize(),
                                     radioButton=currentVar,
                                     c=partial(self.prefFunction, pref, obj))
Example #20
0
def run(parent):
    try:
        context = cmds.currentCtx()
        mode = getMode(context)
        cmds.setParent(parent, menu=True)
        cmds.radioMenuItemCollection()
        cmds.menuItem(label="snap off", rb=mode == 0, rp="NW", c=wrapper(context, 0))
        cmds.menuItem(label="snap relative", rb=mode == 1, rp="N", c=wrapper(context, 1))
        cmds.menuItem(label="snap absolute", rb=mode == 2, rp="NE", c=wrapper(context, 2))
        new_mode = 1 if mode == 0 else mode
        for value, pos in zip(values[context], positions):
            cmds.menuItem(label=str(value), rp=pos, c=wrapper(context, new_mode, value))
    except KeyError:
        pass
Example #21
0
 def commonMenu(self):
     """Create common menu items for all option boxes"""
     self.editMenu = cmds.menu(label='Edit')
     self.editMenuSave = cmds.menuItem(
         label='Save Settings',
         enable=self.supportsSaveSettings,
         command=self.editMenuSaveCmd
     )
     self.editMenuReset = cmds.menuItem(
         label='Reset Settings',
         command=self.editMenuResetCmd
     )
     self.editMenuDiv = cmds.menuItem(d=True)
     self.editMenuRadio = cmds.radioMenuItemCollection()
     self.editMenuTool = cmds.menuItem(
         label='As Tool',
         radioButton=True,
         enable=self.supportsToolAction,
         command=self.editMenuToolCmd
     )
     self.editMenuAction = cmds.menuItem(
         label='As Action',
         radioButton=True,
         enable=self.supportsToolAction,
         command=self.editMenuActionCmd
     )
     self.helpMenu = cmds.menu(label='Help')
     self.helpMenuItem = cmds.menuItem(
         label='Help on %s'%self.title,
         command=self.helpMenuCmd
     )
Example #22
0
 def commonMenu(self):
     """Create common menu items for all option boxes"""
     self.editMenu = cmds.menu(label='Edit')
     self.editMenuSave = cmds.menuItem(
         label='Save Settings',
         command=self.editMenuSaveCmd
     )
     self.editMenuReset = cmds.menuItem(
         label='Reset Settings',
         command=self.editMenuResetCmd
     )
     self.editMenuDiv = cmds.menuItem(d=True)
     self.editMenuRadio = cmds.radioMenuItemCollection()
     self.editMenuTool = cmds.menuItem(
         label='As Tool',
         radioButton=True,
         enable=self.supportsToolAction,
         command=self.editMenuToolCmd
     )
     self.editMenuAction = cmds.menuItem(
         label='As Action',
         radioButton=True,
         enable=self.supportsToolAction,
         command=self.editMenuActionCmd
     )
     self.helpMenu = cmds.menu(label='Help')
     self.helpMenuItem = cmds.menuItem(
         label='Help on %s'%self.title,
         command=self.helpMenuCmd
     )
Example #23
0
    def populateMenu(self, menu, *args):
        uiMod.clearMenuItems(menu)
        uiMod.clearMenuItems(menu)
        #cmds.menuItem(label="Clear motion trails", command=self.clear)
        cmds.radioMenuItemCollection(parent=menu)

        currRange = [
            cmds.playbackOptions(query=True, minTime=True),
            cmds.playbackOptions(query=True, maxTime=True)
        ]
        currRangeStr = "%s   -   %s" % (int(currRange[0]), int(currRange[1]))

        #populate list
        ranges = self.getTimelineRanges()
        if ranges: ranges = eval(ranges)
        if ranges:
            for loopRange in ranges:
                loopRangeStr = "%s   -   %s" % (int(
                    loopRange[0]), int(loopRange[1] - 1))
                radioButton = (currRangeStr == loopRangeStr)
                cmds.menuItem("menu_%s" % loopRange,
                              radioButton=radioButton,
                              label=loopRangeStr,
                              parent=menu,
                              command=lambda x, loopRange=loopRange, *args:
                              self.setTimelineRange(loopRange))
            cmds.menuItem(divider=True, parent=menu)
            newMenu = cmds.menuItem(subMenu=True, label='Delete', parent=menu)
            cmds.menuItem(divider=True, parent=menu)
            for loopRange in ranges:
                loopRangeStr = "%s   -   %s" % (int(
                    loopRange[0]), int(loopRange[1] - 1))
                cmds.menuItem("menu_%s" % loopRange,
                              label=loopRangeStr,
                              parent=newMenu,
                              command=lambda x, loopRange=loopRange, *args:
                              self.deleteTimelineRange(loopRange))
            cmds.menuItem(divider=True, parent=newMenu)
            cmds.menuItem("menu_deleteAll",
                          label="Delete All",
                          parent=newMenu,
                          command=self.deleteAllTimelineRange)
        cmds.menuItem("toggleLipSyncModeMenu",
                      label='Lip Sync Mode',
                      checkBox=self.isLipSyncMode(),
                      command=self.toggleLipSyncMode,
                      parent=menu)
Example #24
0
def build(parent,
          imagesPath,
          iconSize=25,
          height=20,
          marginSize=5):
    """
    build widget
    @param parent : parent layout in maya
    @imagesPath : str path
    """
    cmds.rowLayout(numberOfColumns=3, parent = parent)
    cmds.iconTextButton(style='iconOnly',
                        image1=os.path.join(
                            imagesPath, 'lockdown_reverse.png'),
                        hi=os.path.join(
                            imagesPath, 'lockdown_reverse_hi.png'),
                        width=iconSize, mw=marginSize, height=iconSize, mh=marginSize,
                        label='lock reverse',
                        npm=1,
                        annotation='lock reverse',
                        c=partial(run, 'reverse'))
    UIContainer.textFieldLockDown = cmds.textField(text=3, width=20)
    cmds.popupMenu()
    cmds.radioMenuItemCollection()
    UIContainer.menuItemLDNTranslation = cmds.menuItem(label='translate only', 
                                                    radioButton=True,
                                                    c=partial(writeLDNMode, 'translate'))
    UIContainer.menuItemLDNRotation    = cmds.menuItem(label='rotation only', 
                                                    radioButton=False,
                                                    c=partial(writeLDNMode, 'rotate'))
    UIContainer.menuItemLDNBoth        = cmds.menuItem(label='both', 
                                                    radioButton=False,
                                                    c=partial(writeLDNMode, 'both'))
    cmds.menuItem(divider=True)
    UIContainer.menuItemReset       = cmds.menuItem(label='clear key', c=clearKey)
    cmds.iconTextButton(style='iconOnly',
                        image1=os.path.join(
                            imagesPath, 'lockdown_forward.png'),
                        hi=os.path.join(
                            imagesPath, 'lockdown_forward_hi.png'),
                        width=iconSize, mw=marginSize, height=iconSize, mh=marginSize,
                        label='lock forward',
                        npm=1,
                        annotation='lock forward',
                        c=partial(run, 'forward'))
    cmds.setParent("..")
    readLDNMode()
Example #25
0
 def helpDoc(self):
     if cmds.window('HelpDoc_KitKat', q=1, ex=1):
         cmds.deleteUI('HelpDoc_KitKat')
     cmds.window('HelpDoc_KitKat', t='Help Doc', rtf=1, s=1, tlb=1, wh=(480, 500))
     _iconwh = 60
     cmds.columnLayout(cat=('both', 2), rs=2, cw=480)
     fn = 'fixedWidthFont'
     cmds.rowLayout(nc=2)
     cmds.iconTextButton(st='iconAndTextVertical', i='pi-add.png', w=_iconwh, h=_iconwh, l='Add')
     cmds.popupMenu()
     cmds.menuItem(l='Mirror', c=lambda *args: self.mirrorPose())
     cmds.text(l=u'*初始化PSD(首次添加): 选择骨骼 + 控制器 \n*添加Pose: 选择骨骼/控制器 \n*右键菜单: Mirror功能, 可以镜像单个Pose或整个PSD节点', al='left', fn=fn)
     cmds.setParent('..')
     cmds.rowLayout(nc=2)
     cmds.iconTextButton(st='iconAndTextVertical', i=self.tempIco, w=_iconwh, h=_iconwh, l='Delete')
     cmds.text(l=u'选择一个PSD节点或多个Pose, 进行删除操作', al='left', fn=fn)
     cmds.setParent('..')
     cmds.rowLayout(nc=2)
     cmds.iconTextCheckBox(st='iconAndTextVertical', i='animPrefsWndIcon.png', w=_iconwh, h=_iconwh, l='Edit')
     cmds.text(l=u'选择单个Pose, 将跳转到选择的Pose \n*选择单个Pose, 调出当前修型开始编辑 \n按钮点亮时: 将当前的修型模型,塞回指定的BS', al='left', fn=fn)
     cmds.setParent('..')
     cmds.rowLayout(nc=2)
     cmds.iconTextButton(st="textOnly", l='Bake', h=50, w=_iconwh)
     cmds.text(l=u'*选择一个PSD节点或多个Pose, 提取出修型目标体', al='left', fn=fn)
     cmds.setParent('..')
     cmds.rowLayout(nc=2)
     cmds.iconTextButton(st="textOnly", l='Remake', h=50, w=_iconwh)
     cmds.text(l=u'*选择一个或多个修型目标体, 根据模型信息新增或修改指定Pose', al='left', fn=fn)
     cmds.setParent('..')
     cmds.rowLayout(nc=2)
     cmds.iconTextButton(st='iconAndTextVertical', i='kinMirrorJoint_S.png', l='Filp Target', w=_iconwh, h=52)
     cmds.popupMenu()
     cmds.radioMenuItemCollection()
     cmds.menuItem(l='X', rb=1)
     cmds.menuItem(l='Y', rb=0)
     cmds.menuItem(l='Z', rb=0)
     cmds.text(l=u'*一般模型: 将选择的模型翻转, 得到一个对称的模型 \n*PSD模型: 将选择的修型目标体翻转, 得到一个对称的可通过Remake按钮\n \
                 添加Pose的修型目标体 \n右键菜单: 修改翻转对称轴', al='left', fn=fn)
     cmds.setParent('..')
     cmds.rowLayout(nc=2)
     cmds.iconTextButton(st='iconAndTextVertical', i='substGeometry.png', l='Bake Cloth', w=_iconwh, h=52)
     cmds.text(l=u'*选择一个PSD节点或多个Pose, 将提取出指定Pose时的模型形状?', al='left', fn=fn)
     cmds.setParent('..')
     cmds.text(l=u'带 * 表示需要在 | Load Object | (加载模型)的前提下操作', h=50, fn='obliqueLabelFont')
     cmds.showWindow('HelpDoc_KitKat')
    def createInflListContextMenu(self):
        list = self.controls.inflList
        self.controls.inflListMenu = cmds.popupMenu(parent=list)
        self.controls.menuPinInfluence = cmds.menuItem(label='Pin Influence',
                                                       enable=False)
        self.controls.menuPaintWeights = cmds.menuItem(
            label='Paint Weights',
            enable=False,
            command=self.doInflListPaintWeights)

        cmds.menuItem(divider=True)
        cmds.radioMenuItemCollection()
        self.controls.menuNoLockFilter = cmds.menuItem(
            label='Show Both Locked and Unlocked Influences', radioButton=True)
        self.controls.menuHideLocked = cmds.menuItem(
            label='Hide Locked Influences', radioButton=False)
        self.controls.menuHideUnlocked = cmds.menuItem(
            label='Hide Unlocked Influences', radioButton=False)
 def commonMenu(self):
     self.editMenu = cmds.menu(label='Edit')
     self.editMenuSave = cmds.menuItem(label='Save Settings')
     self.editMenuReset = cmds.menuItem(label='Reset Settings')
     self.editMenuDiv = cmds.menuItem(d=True)
     self.editMenuRadio = cmds.radioMenuItemCollection()
     self.editMenuTool = cmds.menuItem(label='As Tool', radioButton=True, enable=self.supportsToolAction)
     self.editMenuAction = cmds.menuItem(label='As Action', radioButton=True, enable=self.supportsToolAction)
     self.helpMenu = cmds.menu(label='Help')
     self.helpMenuItem = cmds.menuItem(label='Help on %s' % self.title)
Example #28
0
 def populateMenu(self, menu, *args):
                 
     uiMod.clearMenuItems(menu)
     
     cmds.radioMenuItemCollection(parent=menu)
     
     #populate list
     for loopCamera in utilMod.getAllCameras():
         radioSelected = (animMod.getShotCamera() == loopCamera)
         cameraName = cmds.listRelatives(loopCamera, allParents=True)[0]
         cmds.menuItem("menu_%s"%loopCamera, label=str(cameraName), radioButton=radioSelected, parent=menu, command=lambda x, loopCamera=loopCamera, *args: aToolsMod.saveInfoWithScene(STORE_NODE, CAMERA_ATTR, loopCamera))
 
     # last playblast menu
     cmds.menuItem(divider=True, parent=menu)
     checkBoxSelected = aToolsMod.getUserPref("saveAfterPlayblasting", default=True)
     cmds.menuItem("saveAfterPlayblastingMenu", label='Save Maya File After Playblasting', checkBox=checkBoxSelected, command=self.setSaveAfterPlayblastingPref, parent=menu) 
     cmds.menuItem(divider=True, parent=menu)
     cmds.menuItem               (label="Duplicate Selected Camera", command=self.duplicateCamera,   parent=menu)
     cmds.menuItem               (label="Playblast Viewport",        command=self.playblastViewport, parent=menu)
     cmds.menuItem               (label="Play Last Playblast",       command=self.playLastPlayblast, parent=menu)
Example #29
0
 def connectMenu(self, rp=None ):
     
     self.defaultSetting( 'Connect', rp )
     cmds.menuItem( l='translate', rp='N', c=connection.MmConnectEach().translate )
     cmds.menuItem( l='rotate', rp='NE',  c=connection.MmConnectEach().rotate )
     
     cmds.menuItem( l='Scale Shear', rp='E', sm=1 )
     cmds.menuItem( l='scale', rp='E', c=connection.MmConnectEach().scale )
     cmds.menuItem( l='shear', rp='SE', c=connection.MmConnectEach().shear )
     cmds.setParent( '..', menu=1 )
     
     cmds.menuItem( l='Sel Target', rp='SE', sm=1 )
     cmds.radioMenuItemCollection()
     cmds.menuItem( l='Sel Original',radioButton= model.RigToolInfo._selOriginal, c=setConnectionTypeOriginal  )
     cmds.menuItem( l='Sel Parent'  ,radioButton= model.RigToolInfo._selParent, c=setConnectionTypeParent  )
     cmds.setParent( '..', menu=1 )
     
     cmds.menuItem( l='local Connect', rp='S', c=connection.MmConnectEach().localTransform )
     cmds.menuItem( l='Constraint', rp='SW', c=connection.MmConnectEach().constraint )
     cmds.menuItem( l='Const Orient', rp='W', c=connection.MmConnectEach().constraintOrient )
     
     cmds.menuItem( l='Connect All', rp='NW', sm=1 )
     cmds.menuItem( l='translate', rp='N', c=connection.MmConnectAll().translate )
     cmds.menuItem( l='rotate', rp='NE',  c=connection.MmConnectAll().rotate )
     cmds.menuItem( l='scale', rp='E', c=connection.MmConnectAll().scale )
     cmds.menuItem( l='shear', rp='SE', c=connection.MmConnectAll().shear )
     cmds.menuItem( l='local Connect', rp='S', c=connection.MmConnectAll().localTransform )
     cmds.menuItem( l='Constraint', rp='SW', c=connection.MmConnectAll().constraint )
     cmds.menuItem( l='Const Orient', rp='W', c=connection.MmConnectAll().constraintOrient )
     cmds.setParent( '..', menu=1 )
     
     cmds.menuItem( l='Aim Object Connect', c=connection.mmAimObjectConnect )
     cmds.menuItem( l='Blend Two Matrix Connect', c=connection.mmLocalBlendMatrixConnect )
     cmds.menuItem( l='Switch Vis Connect', c=connection.mmSwitchVisConnection )
     cmds.menuItem( l='Get Local mm node', c=connection.mmGetChildMatrix )
     cmds.menuItem( l='Get Local mmdc node', c=connection.mmGetChildDecompose )
     cmds.menuItem( l='Replace by Target', c=connection.mmReplaceByTarget )
     cmds.menuItem( l='Replace connections', c=connection.mmReplaceConnections )
     cmds.menuItem( l='Optimize connections', c=sgRigConnection.mc_optimizeConnection )
Example #30
0
    def populateMenu(self, menu, *args):

        uiMod.clearMenuItems(menu)

        cmds.radioMenuItemCollection(parent=menu)

        #populate list
        for loopCamera in utilMod.getAllCameras():
            radioSelected = (animMod.getShotCamera() == loopCamera)
            cameraName = cmds.listRelatives(loopCamera, allParents=True)[0]
            cmds.menuItem(
                "menu_%s" % loopCamera,
                label=str(cameraName),
                radioButton=radioSelected,
                parent=menu,
                command=lambda x, loopCamera=loopCamera, *args: aToolsMod.
                saveInfoWithScene(STORE_NODE, CAMERA_ATTR, loopCamera))

        # last playblast menu
        cmds.menuItem(divider=True, parent=menu)
        checkBoxSelected = aToolsMod.getUserPref("saveAfterPlayblasting",
                                                 default=True)
        cmds.menuItem("saveAfterPlayblastingMenu",
                      label='Save Maya File After Playblasting',
                      checkBox=checkBoxSelected,
                      command=self.setSaveAfterPlayblastingPref,
                      parent=menu)
        cmds.menuItem(divider=True, parent=menu)
        cmds.menuItem(label="Duplicate Selected Camera",
                      command=self.duplicateCamera,
                      parent=menu)
        cmds.menuItem(label="Playblast Viewport",
                      command=self.playblastViewport,
                      parent=menu)
        cmds.menuItem(label="Play Last Playblast",
                      command=self.playLastPlayblast,
                      parent=menu)
 def commonMenu(self):
     self.editMenu = mc.menu(label='Edit')
     self.editMenuSave = mc.menuItem(label='Save Settings')
     self.editMenuReset = mc.menuItem(label='Reset Settings')
     self.editMenuDiv = mc.menuItem(d=True)
     self.editMenuRadio = mc.radioMenuItemCollection()
     self.editMenuTool = mc.menuItem(label='As Tool',
                                     radioButton=True,
                                     enable=self.supportsToolAction)
     self.editMenuAction = mc.menuItem(label='As Action',
                                       radioButton=True,
                                       enable=self.supportsToolAction)
     self.helpMenu = mc.menu(label='Help')
     self.helpMenuItem = mc.menuItem(label='Help on %s' % self.title,
                                     command=self.helpmenu)
Example #32
0
def build(parent, imagesPath, iconSize=25, height=20, marginSize=5):
    """
    build widget
    @param parent : parent layout in maya
    @imagesPath : str path
    """
    cmds.rowLayout(numberOfColumns=1, parent=parent)
    cmds.iconTextButton(
        style='iconOnly',
        image1=os.path.join(imagesPath, 'mgloc.png'),
        hi=os.path.join(imagesPath, 'mgloc_hi.png'),
        width=iconSize * 1.2,
        mw=marginSize,
        height=iconSize,
        mh=marginSize,
        label='magic locator',
        annotation='select object and it will craete locator per option',
        c=runMagicLocator)
    cmds.popupMenu()
    cmds.radioMenuItemCollection()
    UIContainer.radioMenuItemModeCont = cmds.menuItem(
        label='Constraint to object',
        radioButton=True,
        c=partial(writeMGLMode, 'constraint'))
    UIContainer.radioMenuItemModeBake = cmds.menuItem(label='Bake',
                                                      radioButton=False,
                                                      c=partial(
                                                          writeMGLMode,
                                                          'bake'))
    UIContainer.radioMenuItemModeDrive = cmds.menuItem(label='Drive Object',
                                                       radioButton=False,
                                                       c=partial(
                                                           writeMGLMode,
                                                           'driver'))
    cmds.setParent("..")
    readMGLMode()
Example #33
0
   def populateMenu(self, menu, *args):
       uiMod.clearMenuItems(menu)
       #cmds.menuItem(label="Camera Relative", parent=menu, checkBox=self.cameraRelativeOnOff, command=self.cameraRelativeSwitch)
 
       
       if cmds.objExists(self.mainGroupNode):
           cmds.menuItem(label="Add Selection", parent=menu, command=self.addSelection)
           cmds.menuItem(label="Remove Selection", parent=menu, command=self.removeSelection)
           cmds.menuItem(label="Set Frame Range", parent=menu, command=self.setFrameRange)
           cmds.menuItem( divider=True, parent=menu)
           
           
       if cmds.objExists(self.mainGroupNode):        
           for loopMotionTrail in self.nodeInfo.keys():
               ctrl    =  self.nodeInfo[loopMotionTrail]["ctrlNode"]
               cmds.menuItem(label="Grab Offset Ctrl (%s)"%ctrl, parent=menu, command=lambda x, loopMotionTrail=loopMotionTrail, *args:self.grabOffsetCtrl(loopMotionTrail))
       
           cmds.menuItem( divider=True, parent=menu)
           
       subMenu = cmds.menuItem(label="Preferences", subMenu=True, parent=menu, tearOff=True)
        
       #Pre pos range           
       cmds.radioMenuItemCollection(parent=subMenu)
       rangeSelected = self.getPrePosRange()
       for loopPref in self.prePosRanges:    
           radioSelected = (str(rangeSelected) == str(loopPref))
           cmds.menuItem(label="%s"%loopPref, radioButton=radioSelected, command=lambda x, loopPref=loopPref, *args:self.savePrePosRange(loopPref), parent=subMenu)
       
       #Size     
       cmds.menuItem( divider=True, parent=subMenu)
       cmds.radioMenuItemCollection(parent=subMenu)
       sizeSelected = self.getPrefSize()
       for loopSize in self.customSizes:
           sizeName        = loopSize[0]
           radioSelected   = (str(sizeSelected) == str(sizeName))
           cmds.menuItem(label=utilMod.toTitle(sizeName), radioButton=radioSelected, command=lambda x, sizeName=sizeName, *args:self.savePrefSize(sizeName), parent=subMenu)
       
       # Keys    
       cmds.menuItem( divider=True, parent=subMenu)
       cmds.radioMenuItemCollection(parent=subMenu)
       keySelected = self.getPrefKey()
       for loopPref in self.prefKeys:  
           radioSelected = (str(keySelected) == str(loopPref))
           cmds.menuItem(label="Show %s Keys"%utilMod.toTitle(loopPref), radioButton=radioSelected, command=lambda x, loopPref=loopPref, *args:self.savePrefKey(loopPref), parent=subMenu)
      
       # Camera Relative    
       cmds.menuItem( divider=True, parent=subMenu)
       cmds.menuItem(label="Camera Relative", checkBox=self.cameraRelativeMode, command=self.setCameraRelativeMode, parent=subMenu)
   
       
       cmds.menuItem(divider=True, parent=menu)
       cmds.menuItem(label="Refresh", parent=menu, command=self.refreshMotionTrail)
Example #34
0
    def setupCommonMenu(self):
        # Edit menu
        self.editMenu = cmds.menu(label='Edit')
        self.editMenuSave = cmds.menuItem(label='Save Settings',
                                          command=self.editMenuSaveCmd)
        self.editMenuReset = cmds.menuItem(label='Reset Settings',
                                           command=self.editMenuResetCmd)
        self.editMenuDiv = cmds.menuItem(d=True)  # Divider
        self.editMenuRadio = cmds.radioMenuItemCollection()
        self.editMenuTool = cmds.menuItem(label='As Tool',
                                          radioButton=True,
                                          enable=self.supportsToolAction,
                                          command=self.editMenuAsToolCmd)
        self.editMenuAction = cmds.menuItem(label='As Action',
                                            radioButton=True,
                                            enable=self.supportsToolAction,
                                            command=self.editMenuAsActionCmd)

        # Help menu
        self.helpMenu = cmds.menu(label='Help')
        self.helpMenuItem = cmds.menuItem(label='Help on %s' % self.title,
                                          command=self.helpMenuCmd)
 def commonMenu(self):
     """
     Create common menu items for all option boxes
     """
     # create a menu, which comes below formLayout
     self.editMenu = cmds.menu(label='Edit')
     # create menuItem(s), after menu
     self.editMenuSave = cmds.menuItem(label='Save Settings', command=self.editMenuSaveCmd)
     # since command flag is not a return placeholder, but to point to a callback function; so we can't use func(). 
     # We can also use partial() from functools module to point to callback function, and pass arguments as well.
     # So this will be command=functools.partial(self.editMenuSaveCmd, *args)
     self.editMenuReset = cmds.menuItem(label='Reset Settings', command=self.editMenuResetCmd)
     self.editMenuDiv = cmds.menuItem(divider=True)
     # create a radio menu item collection
     self.editMenuRadio = cmds.radioMenuItemCollection()
     self.editMenuTool = cmds.menuItem(label='As Tool', radioButton=True, 
                                       enable=self.supportsToolAction, 
                                       command=self.editMenuToolCmd)
     self.editMenuAction = cmds.menuItem(label='As Action', radioButton=True, 
                                         enable=self.supportsToolAction, 
                                         command=self.editMenuActionCmd)
     # will create a help on menuBar
     self.helpMenu = cmds.menu(label='Help')
     self.helpMenuItem = cmds.menuItem(label='Help on %s' % self.title, command=self.helpMenuCmd)
Example #36
0
    def createUI(self):

        if cmds.window(self.windowID, exists=True):
            self.deleteUICmd()

        self.window = cmds.window(self.windowID,
                                  title=self.title,
                                  menuBar=True,
                                  sizeable=False,
                                  widthHeight=self.size)
        cmds.menu(label='Mode')
        self.modeMenuRadio = cmds.radioMenuItemCollection()
        cmds.menuItem(label='Full', radioButton=True, command=self.changeMode2)
        cmds.menuItem(label='hierarchy',
                      radioButton=True,
                      command=self.changeMode1)
        cmds.menuItem(label='selected',
                      radioButton=True,
                      command=self.changeMode0)
        cmds.menu(label='Help')
        cmds.menuItem(label='don\'t rely on help')
        cmds.columnLayout()
        cmds.rowLayout(numberOfColumns=3)
        #         cmds.text(label = 'Change joint size')
        cmds.floatSliderGrp(self.sliderID,
                            field=True,
                            value=1,
                            min=0,
                            max=5,
                            fieldMinValue=0,
                            fieldMaxValue=50,
                            label='joint size',
                            changeCommand=self.applyCmd)
        cmds.button(label='apply', command=self.applyCmd)
        cmds.button(label='close', command=self.deleteUICmd)
        cmds.showWindow(self.windowID)
Example #37
0
    def assignCommand( menuUiName, targetPath ):
    
        for root, dirs, names in os.walk( targetPath ):
            root = root.replace( '\\', '/' )
            targets = []
            
            for directory in dirs:
                targets.append( [directory, 'isDir'] )
            
            for name in names:
                extention = name.split( '.' )[-1]
                if not extention.lower() in ['py', 'txt', 'mel']: continue
                f = open( root + '/' + name, 'r' )
                data = f.read()
                f.close() 
                
                if extention in ['mel','melScript']:
                    targets.append( [name, 'from maya import mel\nf = open( "%s", "r" )\ndata = f.read()\nf.close()\nmel.eval( data )' % (root + '/' + name) ] )
                else:
                    targets.append( [name, 'execfile( "%s" )' % (root + '/' + name) ] )
            targets.sort()
            
            targetOnlyNames = []
            for i in range( len( targets ) ):
                target, command = targets[i]
                elsePath = root.replace( targetPath, '' )[1:]
                if not elsePath:
                    parentUIName = menuUiName
                else:
                    parentUIName = SGFileBaseMenu.getUIName( menuUiName, root.split( '/' )[-1] )
                
                targetUIName, label = SGFileBaseMenu.getUINameAndLabel( menuUiName, target )
                
                targetSplits = [ targetSplit for targetSplit in target.split( '.' ) if targetSplit ]
                if targetSplits[0].isdigit():
                    targetOnlyName = targetSplits[1]
                else:
                    targetOnlyName = targetSplits[0]
                
                targetMenuItem = ''
                if targetOnlyName[0] == '@':
                    if targetOnlyName == '@radioCollection':
                        cmds.radioMenuItemCollection( targetUIName, p = parentUIName )
                    else:
                        firstLine = command.split( '\n' )[0]
                        uiName = firstLine.split( "'" )[-2]
                        targetMenuItem = cmds.menuItem( uiName, l=label[1:], c=command, radioButton=False, p = parentUIName )
                        
                elif targetOnlyName[0] == '#':
                    dividerLabel = targetOnlyName[1:].replace( '-', '' )
                    if dividerLabel:
                        if i == 0:
                            cmds.menuItem( targetUIName + 'labelSpace', l='', p=parentUIName )
                        targetMenuItem = cmds.menuItem( targetUIName + targetOnlyName, d=1, dividerLabel=dividerLabel, p=parentUIName )
                    else:
                        targetMenuItem = cmds.menuItem( targetUIName + targetOnlyName, d=1, p=parentUIName )
                else:
                    if command == 'isDir':
                        if MenuName.itHasRadialPosition( targetOnlyName ):
                            RP, menuName = MenuName.getRadialPositionAndMenuName( targetOnlyName )
                            targetMenuItem = cmds.menuItem( targetUIName, l= menuName, sm=1, p=parentUIName, rp=RP, to=1 )
                        else:
                            targetMenuItem = cmds.menuItem( targetUIName, l=targetOnlyName, sm=1, p=parentUIName, to=1 )
                    else:
                        if MenuName.itHasRadialPosition( targetOnlyName ):
                            RP, menuName = MenuName.getRadialPositionAndMenuName( targetOnlyName )
                            targetMenuItem = cmds.menuItem( targetUIName, l=menuName, c=command, p=parentUIName, rp=RP )
                        else:
                            targetMenuItem = cmds.menuItem( targetUIName, l=targetOnlyName, c=command, p=parentUIName )

                if targetMenuItem:
                    iconPath = root + '/ICON_' + targetOnlyName + '.png'
                    if os.path.exists( iconPath ):
                        cmds.menuItem( targetMenuItem, e=1, image= iconPath )
Example #38
0
def mgear_dagmenu_fill(parent_menu, current_control):
    """Fill the given menu with mGear's custom animation menu

    Args:
        parent_menu(str): Parent Menu path name
        current_control(str): current selected mGear control
    """

    # gets current selection to use later on
    _current_selection = cmds.ls(selection=True)

    # get child controls
    child_controls = []
    for ctl in _current_selection:
        [
            child_controls.append(x) for x in get_all_tag_children(
                cmds.ls(cmds.listConnections(ctl), type="controller"))
            if x not in child_controls
        ]

    child_controls.append(current_control)

    # handles ik fk blend attributes
    for attr in cmds.listAttr(current_control, userDefined=True,
                              keyable=True) or []:
        if (not attr.endswith("_blend")
                or cmds.addAttr("{}.{}".format(current_control, attr),
                                query=True,
                                usedAsProxy=True)):
            continue
        # found attribute so get current state
        current_state = cmds.getAttr("{}.{}".format(current_control, attr))
        states = {0: "Fk", 1: "Ik"}

        rvs_state = states[int(not (current_state))]

        cmds.menuItem(parent=parent_menu,
                      label="Switch {} to {}".format(
                          attr.split("_blend")[0], rvs_state),
                      command=partial(__switch_fkik_callback, current_control,
                                      False, attr),
                      image="kinReroot.png")

        cmds.menuItem(parent=parent_menu,
                      label="Switch {} to {} + Key".format(
                          attr.split("_blend")[0], rvs_state),
                      command=partial(__switch_fkik_callback, current_control,
                                      True, attr),
                      image="character.svg")

        cmds.menuItem(parent=parent_menu,
                      label="Range switch",
                      command=partial(__range_switch_callback, current_control,
                                      attr))

        # divider
        cmds.menuItem(parent=parent_menu, divider=True)

    # check is given control is an mGear control
    if cmds.objExists("{}.uiHost".format(current_control)):
        # select ui host
        cmds.menuItem(parent=parent_menu,
                      label="Select host",
                      command=partial(__select_host_callback, current_control),
                      image="hotkeySetSettings.png")

    # select all function
    cmds.menuItem(parent=parent_menu,
                  label="Select child controls",
                  command=partial(__select_nodes_callback, child_controls),
                  image="dagNode.svg")

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # reset selected
    cmds.menuItem(parent=parent_menu,
                  label="Reset",
                  command=partial(reset_all_keyable_attributes,
                                  _current_selection),
                  image="holder.svg")

    # reset all bellow
    cmds.menuItem(parent=parent_menu,
                  label="Reset all bellow",
                  command=partial(reset_all_keyable_attributes,
                                  child_controls))

    # add transform resets
    k_attrs = cmds.listAttr(current_control, keyable=True)
    for attr in ("translate", "rotate", "scale"):
        # checks if the attribute is a maya transform attribute
        if [x for x in k_attrs if attr in x and len(x) == len(attr) + 1]:
            icon = "{}_M.png".format(attr)
            if attr == "translate":
                icon = "move_M.png"
            cmds.menuItem(parent=parent_menu,
                          label="Reset {}".format(attr),
                          command=partial(__reset_attributes_callback,
                                          _current_selection, attr),
                          image=icon)

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # add mirror
    cmds.menuItem(parent=parent_menu,
                  label="Mirror",
                  command=partial(__mirror_flip_pose_callback,
                                  _current_selection, False),
                  image="redrawPaintEffects.png")
    cmds.menuItem(parent=parent_menu,
                  label="Mirror all bellow",
                  command=partial(__mirror_flip_pose_callback, child_controls,
                                  False))

    # add flip
    cmds.menuItem(parent=parent_menu,
                  label="Flip",
                  command=partial(__mirror_flip_pose_callback,
                                  _current_selection, True),
                  image="redo.png")
    cmds.menuItem(parent=parent_menu,
                  label="Flip all bellow",
                  command=partial(__mirror_flip_pose_callback, child_controls,
                                  True))

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # rotate order
    if (cmds.getAttr("{}.rotateOrder".format(current_control), channelBox=True)
            or cmds.getAttr("{}.rotateOrder".format(current_control),
                            keyable=True)
            and not cmds.getAttr("{}.rotateOrder".format(current_control),
                                 lock=True)):
        _current_r_order = cmds.getAttr(
            "{}.rotateOrder".format(current_control))
        _rot_men = cmds.menuItem(parent=parent_menu,
                                 subMenu=True,
                                 tearOff=False,
                                 label="Rotate Order switch")
        cmds.radioMenuItemCollection(parent=_rot_men)
        orders = ("xyz", "yzx", "zxy", "xzy", "yxz", "zyx")
        for idx, order in enumerate(orders):
            if idx == _current_r_order:
                state = True
            else:
                state = False
            cmds.menuItem(parent=_rot_men,
                          label=order,
                          radioButton=state,
                          command=partial(__change_rotate_order_callback,
                                          current_control, order))

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # handles constrains attributes (constrain switches)
    for attr in cmds.listAttr(current_control, userDefined=True,
                              keyable=True) or []:

        # filters switch reference attributes
        if (cmds.addAttr("{}.{}".format(current_control, attr),
                         query=True,
                         usedAsProxy=True)
                or not attr.endswith("ref") and not attr.endswith("Ref")):
            continue

        part, ctl = (attr.split("_")[0],
                     attr.split("_")[-1].split("Ref")[0].split("ref")[0])
        _p_switch_menu = cmds.menuItem(parent=parent_menu,
                                       subMenu=True,
                                       tearOff=False,
                                       label="Parent {} {}".format(part, ctl),
                                       image="dynamicConstraint.svg")
        cmds.radioMenuItemCollection(parent=_p_switch_menu)
        k_values = cmds.addAttr("{}.{}".format(current_control, attr),
                                query=True,
                                enumName=True).split(":")
        current_state = cmds.getAttr("{}.{}".format(current_control, attr))

        for idx, k_val in enumerate(k_values):
            if idx == current_state:
                state = True
            else:
                state = False
            cmds.menuItem(parent=_p_switch_menu,
                          label=k_val,
                          radioButton=state,
                          command=partial(__switch_parent_callback,
                                          current_control, attr, idx, k_val))

    # divider
    cmds.menuItem(parent=parent_menu, divider=True)

    # select all rig controls
    selection_set = cmds.ls(cmds.listConnections(current_control),
                            type="objectSet")
    all_rig_controls = cmds.sets(selection_set, query=True)
    cmds.menuItem(parent=parent_menu,
                  label="Select all controls",
                  command=partial(__select_nodes_callback, all_rig_controls))

    # key all bellow function
    cmds.menuItem(parent=parent_menu,
                  label="Keyframe child controls",
                  command=partial(__keyframe_nodes_callback, child_controls),
                  image="setKeyframe.png")
Example #39
0
    def connectMenu(self, rp=None):

        self.defaultSetting('Connect', rp)
        cmds.menuItem(l='translate',
                      rp='N',
                      c=connection.MmConnectEach().translate)
        cmds.menuItem(l='rotate', rp='NE', c=connection.MmConnectEach().rotate)

        cmds.menuItem(l='Scale Shear', rp='E', sm=1)
        cmds.menuItem(l='scale', rp='E', c=connection.MmConnectEach().scale)
        cmds.menuItem(l='shear', rp='SE', c=connection.MmConnectEach().shear)
        cmds.setParent('..', menu=1)

        cmds.menuItem(l='Sel Target', rp='SE', sm=1)
        cmds.radioMenuItemCollection()
        cmds.menuItem(l='Sel Original',
                      radioButton=model.RigToolInfo._selOriginal,
                      c=setConnectionTypeOriginal)
        cmds.menuItem(l='Sel Parent',
                      radioButton=model.RigToolInfo._selParent,
                      c=setConnectionTypeParent)
        cmds.setParent('..', menu=1)

        cmds.menuItem(l='local Connect',
                      rp='S',
                      c=connection.MmConnectEach().localTransform)
        cmds.menuItem(l='Constraint',
                      rp='SW',
                      c=connection.MmConnectEach().constraint)
        cmds.menuItem(l='Const Orient',
                      rp='W',
                      c=connection.MmConnectEach().constraintOrient)

        cmds.menuItem(l='Connect All', rp='NW', sm=1)
        cmds.menuItem(l='translate',
                      rp='N',
                      c=connection.MmConnectAll().translate)
        cmds.menuItem(l='rotate', rp='NE', c=connection.MmConnectAll().rotate)
        cmds.menuItem(l='scale', rp='E', c=connection.MmConnectAll().scale)
        cmds.menuItem(l='shear', rp='SE', c=connection.MmConnectAll().shear)
        cmds.menuItem(l='local Connect',
                      rp='S',
                      c=connection.MmConnectAll().localTransform)
        cmds.menuItem(l='Constraint',
                      rp='SW',
                      c=connection.MmConnectAll().constraint)
        cmds.menuItem(l='Const Orient',
                      rp='W',
                      c=connection.MmConnectAll().constraintOrient)
        cmds.setParent('..', menu=1)

        cmds.menuItem(l='Aim Object Connect', c=connection.mmAimObjectConnect)
        cmds.menuItem(l='Blend Two Matrix Connect',
                      c=connection.mmLocalBlendMatrixConnect)
        cmds.menuItem(l='Switch Vis Connect',
                      c=connection.mmSwitchVisConnection)
        cmds.menuItem(l='Get Local mm node', c=connection.mmGetChildMatrix)
        cmds.menuItem(l='Get Local mmdc node',
                      c=connection.mmGetChildDecompose)
        cmds.menuItem(l='Replace by Target', c=connection.mmReplaceByTarget)
        cmds.menuItem(l='Replace connections',
                      c=connection.mmReplaceConnections)
        cmds.menuItem(l='Optimize connections',
                      c=sgRigConnection.mc_optimizeConnection)
Example #40
0
def gui():
	'''
	GUI for creating scriptJobs
	'''
	# Get XML Data
	parseXML()
	global mainCol, tsl, sfDisc, tslText, radioCol

	if( cmds.window(win, q=True, ex=True ) ):
		cmds.deleteUI(win)
	if( cmds.windowPref( win, ex=True)):
		cmds.windowPref(win, r=True)
		
	cmds.window(win, title="Script Job Creator", mb=True, w=winWidth2, h=winHeight )
	cmds.menu(label="System")
	cmds.menuItem(label="Script Job Monitor",
		c=Callback(mecScriptJob.gui))
	mainCol = cmds.columnLayout(rs=4, co=["both", 5])
	cmds.rowColumnLayout( nc=2, cw=[[1,winWidth*.4],[2,winWidth*.6]])
	tslText = cmds.text(label="Event Types", w=200, al="center")
	cmds.text(label="Type Desciption", w=300, al="center")
	tsl = cmds.textScrollList( w=200, h=150, append="Select Mode",  en=False,
		sc=Callback(loadDisc))
	sfDisc = cmds.scrollField( w=300, h=150,
		editable=False, wordWrap=True, text='Select event for discription.' )
	cmds.setParent( mainCol )
	
	# Create a radioButton collection
	cmds.frameLayout(label="Script Job Type", labelAlign="center", w=winWidth,
		labelIndent=winWidth/2-50)
	frmType = cmds.formLayout(w=winWidth, h=25)
	
	# cmds.text( l="Choose Script Job Type", w=winWidth, al="center")
	rlType = cmds.rowColumnLayout(nc=4, w=500, cw=[[1,winWidth*.25-15],[2,winWidth*.25],[3,winWidth*.25-10],[4,winWidth*.25]],
								  co=[1,"left", 5])
	radioCol = cmds.radioCollection()
	cmds.radioButton("mecSJEvent", label='event', cl=radioCol, sl=True,
		onCommand=Callback(loadTSL))
	cmds.radioButton("mecSJAttr", label='attributes', cl=radioCol,
		onCommand=Callback(loadTSL) )
	cmds.radioMenuItemCollection("mecSJAttrCol")
	cmds.popupMenu()
	cmds.menuItem("mecAttrCh", label="attributeChange", cl="mecSJAttrCol", rb=True)
	cmds.menuItem("mecAttrDel", label="attributeDeleted", rb=False, cl="mecSJAttrCol")
	cmds.menuItem("mecAttrAdd", label="attributeAdded", rb=False, cl="mecSJAttrCol")
	cmds.setParent("..", m=True)
	
	cmds.radioButton("mecSJCond", label='condition', cl=radioCol,
		onCommand=Callback(loadTSL) )
	cmds.radioMenuItemCollection("mecSJConCol")
	cmds.popupMenu()
	cmds.menuItem("mecCondTrue", label="conditionTrue", rb=True, cl="mecSJConCol")
	cmds.menuItem("mecCondFalse", label="conditionFalse", rb=False, cl="mecSJConCol")
	cmds.menuItem("mecCondChange", label="conditionChange", rb=False, cl="mecSJConCol")
	cmds.setParent("..", m=True)
	
	cmds.radioButton("mecSJNode", label='nodeNameChanged', cl=radioCol,
		onCommand=Callback(loadTSL) )
	
	cmds.setParent(frmType)
	rlType2 = cmds.rowColumnLayout(nc=3, w=500, cw=[[1,winWidth/3],[2,winWidth/3-20],[3,winWidth/3]],
									  co=[1,"right", 10])

	cmds.radioButton("mecSJConn", label='connectionChange', cl=radioCol,
		onCommand=Callback(loadTSL) )
	cmds.radioButton("mecSJUI", label='uiDeleted', cl=radioCol,
		onCommand=Callback(loadTSL) )
	cmds.radioButton("mecSJTime", label='timeChange', cl=radioCol,
		onCommand=Callback(loadTSL) )	
		
	cmds.setParent(frmType)
	
	
	row1 = cmds.rowColumnLayout(nc=2, cw=[[1,winWidth/2+10],[2,winWidth/2-20]])
	# This text and ann will change depending when type of script job is chosen.
	# In the case time this text and field will not be used.
	# Certain scriptJob types will automaticly change the content of this field
	cmds.textFieldGrp("mecSJConLabel", label='Attribute', text='', w=winWidth/2,
		cw=[[1,90], [2,200]],
		ann="")

		
	# This field will recieve which procedure will be exectued when the scriptJob is triggered.
	cmds.textFieldGrp("mecSJProcLabel", label='Procedure: ', text='', w=winWidth/2,
		cw=[1,75],
		ann="What function will the scriptJob call?")
	cmds.formLayout(frmType, edit=True, attachForm=[[rlType, "left", 0], 
		[rlType2, "left", 40], [row1, "left", 0], [rlType, "top", 5]], 
		attachControl=[[rlType2,"top",5,rlType], [row1,"top",5,rlType2]])  
	cmds.formLayout( frmType, e=1, af=[row1, "bottom", 5])
	cmds.setParent(mainCol)
	
	
	frmMid = cmds.formLayout()
	jsLayout = jobSecurity( frmMid )
	jLayout = jobLifeSpan( frmMid )
	
	cmds.formLayout(frmMid, e=1, af=[[jsLayout, "top", 5],[jLayout, "top", 5]],
				    ac=[jLayout, "left", 10, jsLayout])
	
	cmds.setParent( mainCol )


	
	# Script Job UI Connection
	cmds.frameLayout(label="Script Job UI Connection", labelAlign="center", w=winWidth,
		labelIndent=winWidth/2-60)
	frm3 = cmds.formLayout(w=winWidth, h=25)
	row3 = cmds.rowColumnLayout(nc=3, cw=[[1,60], [2,150],[3,100]])
	cmds.checkBox("mecSJParent", label="parent", w=100, v=0,
		ann="Attaches this job to a piece of maya UI. When the UI is destroyed, the job will be killed along with it.")
	cmds.textField("mecSJParentText", text="UINameHere", w=100)
	cmds.checkBox("mecSJReplace", label="replacePrevious", v=0,
		ann="This flag can only be used with the -parent flag. Before the new scriptJob is created, any existing scriptJobs that have the same parent are first deleted.")
	cmds.setParent("..")
	cmds.formLayout(frm3, edit=True, attachForm=[[row3, "left", winWidth/2-140],
		[row3, "top", 5]])  
	cmds.setParent(mainCol)		
	
	# Create the Script Job
	cmds.button(label="Generate Script Job", w=winWidth,
		c=Callback(sjCreateSJ))
	cmds.textField("mecSJPreview", w=winWidth, text="Preview Area",  editable=False)
	cmds.button(label="Execute Script Job! Warning this will activate the scriptJob!", w=winWidth,
		c=Callback(exeScriptJ))
	# Preview Area (Extra)
	# This area will show what the script job is looking like.
	
	# Get radioButton event setup first
	# Attr
	# Condition
	
	# Add elements into textScrollList
	#appendElements( tsl )
	loadTSL()
	cmds.showWindow(win)
Example #41
0
def maya2nuke():
    window = "maya2nuke"
    if cmds.window(window, ex=1): cmds.deleteUI(window)
    cmds.window(window, menuBar=1)
    cmds.menu(tearOff=1, l='Edit')
    cmds.menuItem(l='Calculate Maya Data', c=getAllCamera)
    cmds.menuItem(divider=1)
    cmds.menuItem(l='Generator Nuke Script', c=generator)
    cmds.menuItem(l='Show Nuke Script', c=m2nShowText)
    cmds.menuItem(l='Save Nuke Script As', c=saveNukeScript)
    cmds.menuItem(divider=1)
    cmds.menuItem(l='Rest Setings', c=restSetings)
    cmds.menuItem(l='Exit', c='cmds.deleteUI("maya2nuke")')

    cmds.menu(tearOff=1, l='Type')
    cmds.menuItem('typeAll', l='All', checkBox=1, c=adjOption)
    cmds.menuItem(divider=1)
    cmds.menuItem('typeCamera', l='Camera', checkBox=1, c=setOption)
    cmds.menuItem('typeMesh', l='Mesh', checkBox=1, c=setOption)
    cmds.menu(tearOff=1, l='Animation')
    cmds.menuItem('animAll', l='All', checkBox=1, c=adjOption)
    cmds.menuItem(divider=1)
    cmds.menuItem('animCamera', l='Camera', checkBox=1, c=setOption)
    cmds.menuItem('animMesh', l='Mesh', checkBox=0, c=setOption)
    cmds.menu(tearOff=1, l='Networks')
    cmds.radioMenuItemCollection()
    cmds.menuItem('netNone', l='None', radioButton=0, c=setOption)
    cmds.menuItem('netBace', l='Bace', radioButton=1, c=setOption)
    cmds.menuItem('netContactSheet',
                  l='ContactSheet',
                  radioButton=0,
                  c=setOption)

    cmds.menu(l='Help')
    cmds.menuItem(l='Help', c='m2nShowText("help")')
    cmds.menuItem(l='About', c=aboutThis)
    mianLayout = cmds.formLayout(nd=1000)
    b1 = cmds.outlinerEditor('dirList')
    cmds.outlinerEditor(
        'dirList',
        e=1,
        mainListConnection="worldList",
        selectionConnection="modelList",
        showShapes=0,
        showAttributes=0,
        showConnected=0,
        showAnimCurvesOnly=0,
        autoExpand=0,
        showDagOnly=1,
        ignoreDagHierarchy=0,
        expandConnections=0,
        showNamespace=1,
        showCompounds=1,
        showNumericAttrsOnly=0,
        highlightActive=1,
        autoSelectNewObjects=0,
        doNotSelectNewObjects=0,
        transmitFilters=0,
        showSetMembers=1,
        ##                        setFilter="DefaultAllLightsFilter"
    )
    cmds.cmdScrollFieldExecuter('copytext', vis=0)
    b2 = cmds.textField('filterText', cc=setFilterName, ec=setFilterName)
    b3 = cmds.button(l="Generator", c=generator)
    cmds.formLayout(mianLayout,
                    e=1,
                    attachControl=[(b1, "top", 3, b2), (b1, "bottom", 3, b3)],
                    attachForm=[
                        (b1, "left", 3),
                        (b1, "right", 3),
                        (b2, "top", 3),
                        (b2, "left", 3),
                        (b2, "right", 3),
                        (b3, "bottom", 3),
                        (b3, "left", 3),
                        (b3, "right", 3),
                    ],
                    attachNone=[(b2, "bottom"), (b3, "top")])
    cmds.window(window, e=1, t="maya2nuke", widthHeight=(300, 700))
    cmds.showWindow(window)
    getOption()
Example #42
0
def customMayaMenu():

    gMainWindow = mel.eval('$temp1=$gMainWindow')

    menus = cmds.window(gMainWindow, q=True, menuArray=True)

    found = False

    for menu in menus:

        label = cmds.menu(menu, q=True, label=True)

        if label == "Epic Games":

            found = True

    if found == False:

        customMenu = cmds.menu(parent=gMainWindow, label='Epic Games')

        #tools path

        toolsPath = cmds.internalVar(usd=True) + "mayaTools.txt"

        if os.path.exists(toolsPath):

            f = open(toolsPath, 'r')

            mayaToolsDir = f.readline()

            f.close()

        #ART

        cmds.menuItem(parent=customMenu,
                      label="Animation Rigging Toolset",
                      bld=True,
                      enable=False)

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

        cmds.menuItem(parent=customMenu,
                      label="Character Rig Creator",
                      c=launchSkeletonBuilder)

        cmds.menuItem(parent=customMenu,
                      label="Edit Existing Character",
                      c=editCharacter)

        cmds.menuItem(parent=customMenu,
                      label="Add Character For Animation",
                      c=launchAddCharacter)

        cmds.menuItem(parent=customMenu,
                      label="Animation Interface",
                      c=launchAnimUI)

        cmds.menuItem(parent=customMenu, label="Settings", c=launchARTSettings)

        artHelp = cmds.menuItem(parent=customMenu, label="Help", subMenu=True)

        cmds.menuItem(parent=artHelp,
                      label="Learning Videos",
                      c=launchLearningVideos)

        cmds.menuItem(parent=artHelp,
                      label="Help Documentation",
                      c=launchRigHelp)

        cmds.menuItem(parent=artHelp, label="About", c=aboutARTTools)

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

        cmds.menuItem(parent=customMenu,
                      label="Misc. Tools",
                      bld=True,
                      enable=False)

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

        #PERFORCE

        p4Menu = cmds.menuItem(parent=customMenu,
                               label="Perforce",
                               subMenu=True,
                               to=True)

        cmds.menuItem("perforceSubmitMenuItem",
                      parent=p4Menu,
                      label="Submit Current File",
                      enable=False,
                      c=p4Submit)

        cmds.menuItem("perforceAddAndSubmitMenuItem",
                      parent=p4Menu,
                      label="Add and Submit Current File",
                      enable=False,
                      c=p4AddSubmit)

        cmds.menuItem("perforceCheckOutMenuItem",
                      parent=p4Menu,
                      label="Check Out Current File",
                      enable=False,
                      c=p4CheckOut)

        cmds.menuItem("perforceFileHistoryMenuItem",
                      parent=p4Menu,
                      label="Current File History",
                      enable=False,
                      c=p4GetHistory)

        cmds.menuItem("perforceGetLatestMenuItem",
                      parent=p4Menu,
                      label="Get Latest Revision of Current File",
                      enable=False,
                      c=p4GetLatest)

        cmds.menuItem("perforceProjectList",
                      parent=p4Menu,
                      label="Set Project",
                      enable=False,
                      subMenu=True)

        cmds.menuItem("perforceProject_New",
                      parent="perforceProjectList",
                      label="New Project",
                      c=createNewProj)

        cmds.radioMenuItemCollection("perforceProjectRadioMenuCollection",
                                     parent="perforceProjectList")

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

        #check settings to see if use source control is turned on

        toolsPath = cmds.internalVar(usd=True) + "mayaTools.txt"

        if os.path.exists(toolsPath):

            f = open(toolsPath, 'r')

            mayaToolsDir = f.readline()

            f.close()

            settingsLocation = mayaToolsDir + "/General/Scripts/projectSettings.txt"

            if os.path.exists(settingsLocation):

                f = open(settingsLocation, 'r')

                settings = cPickle.load(f)

                f.close()

                #find use source control value

                sourceControl = settings.get("UseSourceControl")

                if sourceControl:

                    cmds.menuItem("perforceSubmitMenuItem",
                                  edit=True,
                                  enable=True)

                    cmds.menuItem("perforceAddAndSubmitMenuItem",
                                  edit=True,
                                  enable=True)

                    cmds.menuItem("perforceCheckOutMenuItem",
                                  edit=True,
                                  enable=True)

                    cmds.menuItem("perforceFileHistoryMenuItem",
                                  edit=True,
                                  enable=True)

                    cmds.menuItem("perforceGetLatestMenuItem",
                                  edit=True,
                                  enable=True)

                    cmds.menuItem("perforceProjectList",
                                  edit=True,
                                  enable=True)

                    #launch script job for checking Maya Tools

                    cmds.scriptJob(event=["NewSceneOpened", autoUpdateTools])
Example #43
0
    def assignCommand(targetPath):

        import sgBFunction_fileAndPath
        locusPath = sgBFunction_fileAndPath.getLocusCommPackagePrefsPath()
        radioButtonInfoPath = sgBFunction_fileAndPath.getLocusCommPackagePrefsPath(
        ) + '/radioButtonInfo'

        for root, dirs, names in os.walk(targetPath):
            root = root.replace('\\', '/')
            targets = []

            for dir in dirs:
                targets.append([dir, 'isDir'])

            for name in names:
                extention = name.split('.')[-1]
                f = open(root + '/' + name, 'r')
                data = f.read()
                f.close()

                if extention in ['mel', 'melScript']:
                    targets.append([
                        name,
                        "import maya.mel\nmaya.mel.eval('source \"%s\"')" %
                        (root + '/' + name)
                    ])
                else:
                    if data.find('%') != -1:
                        targets.append(
                            [name,
                             'execfile( "%s" )' % (root + '/' + name)])
                    else:
                        targets.append([name, data])
            targets.sort()

            for i in range(len(targets)):
                target, command = targets[i]
                splits = root.replace(targetPath, '')[1:].split('.')
                if len(splits) == 1:
                    parentUIName = _3dGroupMenu
                else:
                    parentUIName = getUIName(root.split('/')[-1])

                targetUIName, label = getUINameAndLabel(target)

                targetOnlyName = target.split('.')[1]
                if targetOnlyName[0] == '@':
                    if targetOnlyName == '@radioCollection':
                        cmds.radioMenuItemCollection(targetUIName,
                                                     p=parentUIName)
                    else:
                        firstLine = command.split('\n')[0]
                        uiName = firstLine.split("'")[-2]
                        cmds.menuItem(uiName,
                                      l=label[1:],
                                      c=command,
                                      radioButton=False,
                                      p=parentUIName)

                elif targetOnlyName[0] == '#':
                    dividerLabel = targetOnlyName[1:].replace('-', '')
                    if dividerLabel:
                        if i == 0:
                            cmds.menuItem(targetUIName + 'labelSpace',
                                          l='',
                                          p=parentUIName)
                        cmds.menuItem(targetUIName + targetOnlyName,
                                      d=1,
                                      dividerLabel=dividerLabel,
                                      p=parentUIName)
                    else:
                        cmds.menuItem(targetUIName + targetOnlyName,
                                      d=1,
                                      p=parentUIName)
                else:
                    if command == 'isDir':
                        cmds.menuItem(targetUIName,
                                      l=label,
                                      sm=1,
                                      p=parentUIName,
                                      to=1)
                    else:
                        cmds.menuItem(targetUIName,
                                      l=label,
                                      c=command,
                                      p=parentUIName)

        for root, dirs, names in os.walk(radioButtonInfoPath):
            for name in names:
                command = cmds.menuItem(name, q=1, c=1)
                tempFilePath = locusPath + '/~~tempFile'
                f = open(tempFilePath, 'w')
                f.write(command)
                f.close()
                execfile(tempFilePath)
                os.remove(tempFilePath)

                cmds.menuItem(name, e=1, radioButton=True)

            break
Example #44
0
 def create(self):
     
     import ui_menuEditor
     
     try:self.clearMenu()
     except:
         cmds.warning( "Clear Mesh Error" )
     try:self.clearPopupCa()
     except:
         cmds.warning( "Clear Popup(Ctrl + Alt) Error" )
     try:self.clearPopupSa()
     except:
         cmds.warning( "Clear Popup(Shift + Alt) Error" )
     
     if cmds.menu( self.mainMenu, q=1, ex=1 ):
         cmds.deleteUI( self.mainMenu )
     cmds.menu( self.mainMenu, p='MayaWindow', l= self.label, to=1  )
     
     cmds.menuItem( l= 'UI - List Menu Paths', p= self.mainMenu, c= loadMenuPathEditor,
                    image= os.path.dirname( __file__ ) + '/icons/list.png' )
     cmds.menuItem( l= 'UI - Menu Editor', p= self.mainMenu, c= ui_menuEditor.show,
                    image='' )
     cmds.menuItem( d=1, dl="Main Menu", p=self.mainMenu )
     
     for menuPath in getMenuPaths( Menu_Global.menuListFile ):
         menuChecked = self.isMenuChecked( menuPath )
         dirname = Menu_Global.getMenuLabel( menuPath )
         menuName = cmds.menuItem( l= dirname, p= self.mainMenu, cb=menuChecked )
         cmds.menuItem( menuName, e=1, c= partial( self.selectMenu, menuName, menuPath ) )
         if menuChecked: self.selectMenu( menuName, menuPath )
     
     cmds.menuItem( d=1, dl="Popup Menu( Shift + alt + RMB )", p=self.mainMenu )
     popupShiftAlt = cmds.menuItem( l="Popup Menu( Shift + alt + RMB )", p=self.mainMenu, sm=1 )
     cmds.radioMenuItemCollection( p = popupShiftAlt )
     cmds.menuItem( l= "Clear", p= popupShiftAlt, rb=1, c=self.clearPopupSa )
     for menuPath in getMenuPaths( Menu_Global.popupListFile_sa ):
         popupChecked = self.isPopupChecked( menuPath, 'sa' )
         dirname = Menu_Global.getMenuLabel( menuPath )
         popupName = cmds.menuItem( l= dirname, p= popupShiftAlt, rb=popupChecked )
         cmds.menuItem( popupName, e=1, c= partial( self.selectPopup, menuPath, 'sa' ), p=popupShiftAlt )
         if popupChecked: self.selectPopup( menuPath, 'sa' )
     
     cmds.menuItem( d=1, dl="Popup Menu( Ctrl + alt + RMB )", p=self.mainMenu )
     popupCtrlAlt = cmds.menuItem( l="Popup Menu( Shift + alt + RMB )", p=self.mainMenu, sm=1 )
     cmds.radioMenuItemCollection( p = popupCtrlAlt )
     cmds.menuItem( l= "Clear", p= popupCtrlAlt, rb=1, c=self.clearPopupCa )
     for menuPath in getMenuPaths( Menu_Global.popupListFile_ca ):
         popupChecked = self.isPopupChecked( menuPath, 'ca' )
         dirname = Menu_Global.getMenuLabel( menuPath )
         popupName = cmds.menuItem( l= dirname, p= popupCtrlAlt, rb=popupChecked )
         cmds.menuItem( popupName, e=1, c= partial( self.selectPopup, menuPath, 'ca' ) )
         if popupChecked: self.selectPopup( menuPath, 'ca' )
     
     cmds.menuItem( d=1, dl="", p=self.mainMenu )
     cmds.menuItem( l="Get Icon", p=self.mainMenu, c="import webbrowser;url = 'http://www.flaticon.com/';webbrowser.open_new_tab( url )",
                    image = os.path.dirname( __file__ ) + '/icons/search.png')
     cmds.menuItem( d=1, dl="", p=self.mainMenu )
     cmds.menuItem( l="Reload Modules", c=reloadModules, p=self.mainMenu )
     cmds.menuItem( d=1, dl="", p=self.mainMenu )
     cmds.menuItem( l="Reload Menu", c=loadMenu, p=self.mainMenu, 
                    image = os.path.dirname( __file__ ) + '/icons/reload.png' )
Example #45
0
	def commonMenu(self):
		self.editMenu = mc.menu(label = 'Edit');
		#self.editMenuSave = mc.menuItem(
		#	label='Save Settings',
		#	command = self.editMenuSaveCmd
		#);
		#self.editMenuReset = mc.menuItem(
		#	label = 'Reset Settings',
		#	command = self.editMenuResetCmd
		#);
		self.editMenuDiv = mc.menuItem(
			d=True
		);
		self.editMenuskelRadio = mc.radioMenuItemCollection();
		self.editMenuTool = mc.menuItem(
			label = 'As Tool',
			radioButton = True,
			enable = self.supportsToolAction,
			command = self.editMenuToolCmd
		);
		#self.editMenuAction = mc.menuItem(
		#	label = 'As Action',
		#	radioButton = True,
		#	enable = self.supportsToolAction,
		#	command = self.editMenuActionCmd
		#);
		self.helpMenu = mc.menu(label = 'Help');
		self.helpMenuItem = mc.menuItem(
			label = 'Help on %s' %self.title,
			command = self.helpMenuCmd
		);
		
		mc.columnLayout(columnAttach=('both', 2), rowSpacing=4,columnWidth=340)	
		mc.text("QUADRUPED CHARACTER", align="center")
		mc.text("")
		mc.text("Step 1: Create quadruped skeleton")

		self.buttonSkelQuad = mc.button(label = 'Quadruped Skeleton',command = self.skeletonButton_Q, width = 120, height = 40);	
		
		mc.text("  ")
		mc.text("Step 2: Create Legs control")
		
		mc.text("____________________________________")
		mc.text( label='REAR BODY CONTROL', align='center' )
		
		buttonMirrorJoints =  mc.button(label = 'Mirror Joints',command = self.MirrorJoints, width = 120, height = 40);
		
		buttonRigFrontLegsCtrl = mc.button(label = 'Front Legs Control',command = self.Front_Legs_Control, width = 120, height = 40);
		
		buttonRigRearLegsCtrl = mc.button(label = 'Rear Legs Control',command = self.Rear_Legs_Control, width = 120, height = 40);
		
		buttonRigSpineCtrl = mc.button(label = 'Spine Control',command = self.Spine_Control, width = 120, height = 40,align="center");
		mc.text("  ")
		mc.text("Step 3: Create Neck/Head controls")
		mc.text("__________________________________")
		mc.text( label='FRONT BODY CONTROL', align='center' )
		
		buttonRigNeckCtrl = mc.button(label = 'Neck Control',command = self.Neck_Control, width=120, height=40);
		
		buttonRigHeadCtrl = mc.button(label = 'Head Control', command = self.Head_Control,width=120, height=40)
		
		buttonRigJawCtrl = mc.button(label = "Jaw Control", command = self.Jaw_Control, width=120, height=40)
		buttonRigTongueCtrl = mc.button(label = "Tongue Control", command = self.Tongue_Control, width=120, height=40)
		mc.text("   ")
		mc.text("Step 4: Create Tail Control")
		buttonRigTailCtrl = mc.button(label = "Tail Control", command = self.Tail_Control, width=120, height=40)
		mc.text("   ")
		mc.text("Step 5: Create Master control")
		mc.text("___________________________________")
		mc.text("MASTER CONTROL",align='center')
		buttonMainCtrl = mc.button(label = 'Master Control', command = self.Master_Control, width = 120, height = 40,align='center')
		closeButton = mc.button(label = "Close", command= self.closeWindow, width = 120, height = 40,align='center')
Example #46
0
def channelbox_menu_rebuild(box, menu, menu_items, popup, *args):  # build the menu when a menu is opened
    def menu_counter(items):
        if items[2] is not "":  # if a parent is set then this is an item of the given type
            if items[1] >= items[0]:  # then we've completed the last item for the given type
                items = [0, 0,
                         ""]  # resets the array, clearing parent allows next menu item to know it's not a given type
            else:
                items[1] += 1  # counter for remaining amount of items
        return items

    cmds.menu(menu, e=1, deleteAllItems=1) if popup else cmds.popupMenu(menu, e=1, deleteAllItems=1)

    # initialize required variables
    sub = [0, 0, ""]  # [total submenu items, remaining, submenu parent]
    radio = [0, 0, "", ""]  # [total radio items, remaining, radio parent, radio key]
    radio_key = ""
    last_added_type = ""  #

    if box.saved_states["popupLabel"][0] and popup:  # draw title label on popup menu if desired
        # print [key for key, menu in box.menus.iteritems() if menu == menu_items]
        # print menu
        cmds.menuItem(l=[key for key, value in box.menus.iteritems() if value == menu_items][0],
                      p=menu)  # Gets the label from the menu key in box.menus by looping through the dict
        # for menu_items identical to the given one
        cmds.menuItem(divider=1, p=menu)

    for key, values in menu_items.iteritems():
        label = values[0]  # display name
        selected_only = values[1]  # only enable if attributes are selected
        item_type = values[2]  # eg default, checkbox, submenu, radio button
        command = values[3]  # function used as command
        tooltip = "" if not len(values) == 5 else values[4]

        enabled = 1  # should enable or disable?
        no_edit = 0  # should add partial command?
        parent = menu  # compensate for adding submenu items to correct parent

        if sub[2] != "":  # submenu counter is active, this item is in a submenu
            parent = sub[2]
        elif radio[2] != "":  # radio counter is active, this item is in a radio collection
            parent = radio[2]

        if selected_only:  # check if this only gets enabled when an attribute is selected
            enabled = channelbox_menu_states(box, key, key)  # check if attribute is selected
            if not enabled and box.saved_states["hideUnavailable"][
                0]:  # if chosen not to display unavailable attributes nothing more needs doing, move on
                continue

        if item_type == "divider":
            if last_added_type != "divider":  # prevent stacking dividers when disabled options are hidden
                cmds.menuItem(divider=1, p=parent)
                last_added_type = item_type
            continue

        if item_type == "custom":
            channelbox_menu_custom(box, key, item_type, label, command, parent, enabled)
            last_added_type = item_type
            continue

        if "radio" in item_type:
            radio[0] = values[3]  # how many following items are put in radio collection
            radio[1] = 0
            m_item = cmds.radioMenuItemCollection(p=parent)
            radio[2] = m_item
            radio_key = key
            last_added_type = item_type
            continue

        if "checkbox" in item_type:
            m_item = cmds.menuItem(l=label, en=enabled, cb=box.saved_states[key][0] if key in box.saved_states else 0,
                                   annotation=tooltip, p=parent)
            if command != "":
                cmds.menuItem(m_item, e=1, c=sysCmd.rpartial(command, box, m_item, key, label))
            no_edit = 1
        elif "submenu" in item_type:
            sub[0] = values[3]  # how many following items are put in submenu
            sub[1] = 0
            m_item = cmds.menuItem(l=label, en=enabled, subMenu=1, p=parent)
            sub[2] = m_item  # set the parent for the submenus created after this
            no_edit = 1
        elif radio[2] is not "":  # radio counter is active
            if radio_key in box.saved_states:
                if radio[0] >= 2:
                    which_radio = radio[1] == box.saved_states[radio_key][0] - 1
                else:
                    which_radio = 0 if box.saved_states[radio_key][0] - 1 == radio[
                        1] else 1  # can't use division on a 0, nor do we need to shift the range for 2 numbers
            else:
                which_radio = 1 if radio[1] == 0 else 0  # no setting, assume the first item is selected by default
            m_item = cmds.menuItem(l=label, en=enabled, radioButton=which_radio, annotation=tooltip, p=parent)
            if command != "":
                cmds.menuItem(m_item, e=1, c=partial(command, box, m_item, key))
            no_edit = 1
        else:
            m_item = cmds.menuItem(l=label, en=enabled, annotation=tooltip, p=parent)
            if item_type == "optionbox":
                m_item2 = cmds.menuItem(m_item, ob=1, p=parent)
                if command != "":
                    cmds.menuItem(m_item2, e=1, c=sysCmd.rpartial(command, box, m_item2, key, label))

        if not no_edit:
            if command != "":
                cmds.menuItem(m_item, e=1, c=sysCmd.rpartial(command, box, m_item, key, label if sub[
                    2] == "" else "> " + label))  # add command after declaration to provide itself as parameter

        sub = menu_counter(sub)
        radio = menu_counter(radio)
        last_added_type = item_type
def customMayaMenu():
    gMainWindow = mel.eval('$temp1=$gMainWindow')
    
    
    menus = cmds.window(gMainWindow, q = True, menuArray = True)
    found = False
    for menu in menus:
        label = cmds.menu(menu, q = True, label = True)
        if label == "Epic Games":
            found = True
    
    if found == False:
        customMenu = cmds.menu(parent=gMainWindow, label = 'Epic Games')
        
        #tools path
	toolsPath = cmds.internalVar(usd = True) + "mayaTools.txt"
	if os.path.exists(toolsPath):
	    
	    f = open(toolsPath, 'r')
	    mayaToolsDir = f.readline()
	    f.close()	
	    
        #ART
	cmds.menuItem(parent = customMenu, label = "Animation Rigging Toolset", bld = True, enable = False)
	cmds.menuItem(parent = customMenu, divider = True)
	cmds.menuItem(parent = customMenu, label = "Character Rig Creator", c = launchSkeletonBuilder)
	cmds.menuItem(parent = customMenu, label = "Edit Existing Character", c = editCharacter)
	cmds.menuItem(parent = customMenu, label = "Add Character For Animation", c = launchAddCharacter)
	cmds.menuItem(parent = customMenu, label = "Animation Interface", c = launchAnimUI)
	
	cmds.menuItem(parent = customMenu, label = "Settings", c = launchARTSettings)
        artHelp = cmds.menuItem(parent = customMenu, label = "Help", subMenu=True)
	cmds.menuItem(parent = artHelp, label = "Learning Videos", c = launchLearningVideos)
	cmds.menuItem(parent = artHelp, label = "Help Documentation", c = launchRigHelp)
        cmds.menuItem(parent = artHelp, label = "About", c = aboutARTTools)
	cmds.menuItem(parent = customMenu, divider = True)
	cmds.menuItem(parent = customMenu, label = "Misc. Tools", bld = True, enable = False)
	cmds.menuItem(parent = customMenu, divider = True)
	


	#PERFORCE
	p4Menu = cmds.menuItem(parent = customMenu, label = "Perforce", subMenu=True, to = True)
	cmds.menuItem("perforceSubmitMenuItem", parent = p4Menu, label = "Submit Current File", enable = False, c = p4Submit)
	cmds.menuItem("perforceAddAndSubmitMenuItem", parent = p4Menu, label = "Add and Submit Current File", enable = False, c = p4AddSubmit)
	cmds.menuItem("perforceCheckOutMenuItem", parent = p4Menu, label = "Check Out Current File", enable = False, c = p4CheckOut)
	cmds.menuItem("perforceFileHistoryMenuItem", parent = p4Menu, label = "Current File History", enable = False, c = p4GetHistory)
	cmds.menuItem("perforceGetLatestMenuItem", parent = p4Menu, label = "Get Latest Revision of Current File", enable = False, c = p4GetLatest)
	cmds.menuItem("perforceProjectList", parent = p4Menu, label = "Set Project", enable = False, subMenu = True)
	cmds.menuItem("perforceProject_New", parent = "perforceProjectList", label = "New Project", c = createNewProj)
	cmds.radioMenuItemCollection("perforceProjectRadioMenuCollection", parent = "perforceProjectList")
	cmds.menuItem(parent = customMenu, divider = True)
	
	

	
	
	
	
	#check settings to see if use source control is turned on
	toolsPath = cmds.internalVar(usd = True) + "mayaTools.txt"
	if os.path.exists(toolsPath):
	    
	    f = open(toolsPath, 'r')
	    mayaToolsDir = f.readline()
	    f.close()	

	    settingsLocation = mayaToolsDir + "/General/Scripts/projectSettings.txt"
	    
	    if os.path.exists(settingsLocation):
		f = open(settingsLocation, 'r')
		settings = cPickle.load(f)
		f.close()	
		
		#find use source control value
		sourceControl = settings.get("UseSourceControl")
		
		if sourceControl:
		    cmds.menuItem("perforceSubmitMenuItem", edit = True, enable = True)
		    cmds.menuItem("perforceAddAndSubmitMenuItem", edit = True, enable = True)
		    cmds.menuItem("perforceCheckOutMenuItem", edit = True, enable = True)
		    cmds.menuItem("perforceFileHistoryMenuItem", edit = True, enable = True)
		    cmds.menuItem("perforceGetLatestMenuItem", edit = True, enable = True)
		    cmds.menuItem("perforceProjectList", edit = True, enable = True)
		    
		    #launch script job for checking Maya Tools
		    cmds.scriptJob(event = ["NewSceneOpened", autoUpdateTools])
Example #48
0
    def _createUI(self):

        flg = logging.getLogger("lettuce.createUI")

        if mc.window(self.uiWindow, exists=True):
            mc.deleteUI(self.uiWindow)

        mc.window(self.uiWindow,
                  title="{}".format(self.title),
                  menuBar=True,
                  sizeable=False
                  )

        mc.window(self.uiWindow,
                  widthHeight=(406, 202),
                  edit=True,
                  )

        flg.info("Window Created")

        mc.menu("file_menu",
                parent=self.uiWindow,
                label="File",
                tearOff=False
                )
        mc.menuItem(label="Copy ALL Descriptions",
                    command=lambda *_: self._copy_all_desc()
                    )
        mc.menuItem(label="Import ALL Character's Hair",
                    command=lambda *_: self._import_all_hair()
                    )
        mc.menuItem(label="Delete ALL Character's Hair",
                    command=lambda *_: self._delete_all_hair()
                    )
        mc.menuItem(label="Refresh Scene",
                    command=lambda *_: self.refresh_scene()
                    )
        mc.menuItem(label="Reload",
                    command=lambda *_: self._reloadUI("masterFrame")
                    )

        mc.menu("edit_menu",
                parent=self.uiWindow,
                label="Edit",
                tearOff=False
                )
        mc.menuItem(label="XML Path",
                    command=lambda *_: self._xml_path_menu()
                    )
        mc.menuItem(label="Log Path",
                    command=lambda *_: self._log_path_menu()
                    )
        mc.menuItem("lg_lvl_menu",
                    label="Log Level",
                    subMenu=True
                    )
        mc.radioMenuItemCollection(parent="lg_lvl_menu")
        mc.menuItem(label="Debug",
                    radioButton=self._check_log_level(10),
                    command=lambda *_: self._change_logging_level("logging.DEBUG")
                    )
        mc.menuItem(label="Info",
                    radioButton=self._check_log_level(20),
                    command=lambda *_: self._change_logging_level("logging.INFO")
                    )
        mc.menuItem(label="Warning",
                    radioButton=self._check_log_level(30),
                    command=lambda *_: self._change_logging_level("logging.WARNING")
                    )
        mc.menuItem(label="Error",
                    radioButton=self._check_log_level(40),
                    command=lambda *_: self._change_logging_level("logging.ERROR")
                    )
        mc.menuItem(label="Critical",
                    radioButton=self._check_log_level(50),
                    command=lambda *_: self._change_logging_level("logging.CRITICAL")
                    )

        mc.menu("help_menu",
                parent=self.uiWindow,
                label="Help",
                helpMenu=True
                )
        mc.menuItem(label="Documentation",
                    command=lambda *_: self._documentation()
                    )

        flg.info("Menu Bar Created")

        mc.frameLayout('masterFrame',
                       label='',
                       width=400,
                       labelVisible=False,
                       marginWidth=0
                       )

        flg.info("Master Frame Created")

        if self.xml_load_state:
            flg.info("XML File Loaded")
            self.char_in_scene_list = self._get_characters(self.char_xml_file)

            if len(self.char_in_scene_list) > 0:
                self.char_in_scene = True
                flg.info("Characters verified in Scene")
            else:
                self.char_in_scene = False
                flg.info("Characters verified not in scene")

        if self.char_in_scene:
            flg.info("Creating Character Menus")
            self._create_character_frame(self.char_in_scene_list, "masterFrame")
        else:
            flg.info("Added reload button ")
            mc.button('reloadButton',
                      label="Reload",
                      command=lambda *_: self._reloadUI("masterFrame")
                      )

        # Last UI line

        flg.info("Showing UI...")
        mc.showWindow(self.uiWindow)
import traceback
Example #50
0
    def populateMenu(self, menu, *args):
                  
        uiMod.clearMenuItems(menu)
        
        tokenCustomDivider  = False 
        selObjects          = cmds.ls(selection=True)
        
        if not selObjects: return    
        
        channels    = animMod.getAllChannels()
        channelList = {}
        tokenList   = []
               
        for n, loopObjectChannel in enumerate(channels):
            obj = selObjects[n]
            if loopObjectChannel:
                for loopChannel in loopObjectChannel:
                    tokens = animMod.getTokens(obj, loopChannel)
                    if tokens and len(tokens) > 1: 
                        if not channelList.has_key(loopChannel): channelList[loopChannel] = {"objects":[], "tokens":[]}
                        channelList[loopChannel]["objects"].append(obj)
                        channelList[loopChannel]["tokens"].append(tokens)
                        
        
        for loopChannelList in channelList:
            newMenu         = cmds.menuItem(subMenu=True, label=utilMod.toTitle(loopChannelList), parent=menu)
            objects         = channelList[loopChannelList]["objects"]
            tokens          = channelList[loopChannelList]["tokens"]
            mergedTokens    = utilMod.mergeLists(tokens)                      
            tokenDict       = []
            
            for loopMergedTokens in mergedTokens:
                tokenDict.append({"token":loopMergedTokens, "objects":[]})
                for n, loopObject in enumerate(objects):
                    t = tokens[n]
                    if loopMergedTokens in t:
                        tokenDict[-1]["objects"].append(loopObject)  
        
            cmds.radioMenuItemCollection(parent=menu)            
            
            for n, loopTokenDict in enumerate(tokenDict):
                tokenCustomDivider  = True
                token               = loopTokenDict["token"]
                objects             = loopTokenDict["objects"]
                selectedList        = [cmds.getAttr("%s.%s"%(loopObj, loopChannelList)) for loopObj in objects]                
                radioSelected       = False
                
                
                if len(set(selectedList)) == 1:
                    if selectedList[0] == n:
                        radioSelected   = True
                
                cmds.menuItem(label=utilMod.toTitle(token), radioButton=radioSelected, parent=newMenu, command=lambda x, objects=objects, channel=loopChannelList, token=token, *args:self.spaceSwitch([objects, channel, token]))
            
             
            #ALL KEYS
            cmds.menuItem( divider=True, parent=newMenu)
            newMenu = cmds.menuItem(subMenu=True, label='All Keys', parent=newMenu)
            
            cmds.radioMenuItemCollection(parent=newMenu)
            
            for n, loopTokenDict in enumerate(tokenDict):
                token           = loopTokenDict["token"]
                objects         = loopTokenDict["objects"]
                selectedList    = [cmds.getAttr("%s.%s"%(loopObj, loopChannelList)) for loopObj in objects]                
                radioSelected   = False
                
                if len(set(selectedList)) == 1:
                    if selectedList[0] == n:
                        radioSelected   = True
                
                cmds.menuItem(label=utilMod.toTitle(token), radioButton=radioSelected, parent=newMenu, command=lambda x, objects=objects, channel=loopChannelList, token=token, *args:self.spaceSwitch([objects, channel, token], all=True))

        # CUSTOM SWITCH
        allCustomSwitch     = aToolsMod.loadInfoWithUser("spaceSwitch", "customSwitch") or []
        channelboxSelObjs   = animMod.channelBoxSel()
        
        if channelboxSelObjs:
            obj            = ".".join(channelboxSelObjs[0].split(".")[:-1])
            selectedSwitch = [loopAttr.split(".")[-1] for loopAttr in channelboxSelObjs if utilMod.isDynamic(obj, loopAttr.split(".")[-1])]
            if len(selectedSwitch) > 0 and selectedSwitch not in allCustomSwitch: 
                allCustomSwitch.append(selectedSwitch)            
                aToolsMod.saveInfoWithUser("spaceSwitch", "customSwitch", allCustomSwitch)  
        
        
        # populate menu
        if len(allCustomSwitch) > 0:  
                
            divider             = False
            customSwitchesAdded = []
            customSwitchesMenu  = []
            
            for loopObj in selObjects:
                       
                for loopCustomSwitch in sorted(allCustomSwitch, key=len, reverse=True):
                    
                    if len(loopCustomSwitch) == 0: continue                    
                    
                    switchName  = utilMod.getNameSpace([loopObj])[1][0].split(".")[0]
                    exit        = False
                    
                    for loopAttr in loopCustomSwitch:
                        objAttr = "%s.%s"%(loopObj, loopAttr)
                        if not cmds.objExists(objAttr):
                            exit = True
                            break
                            
                    if exit: continue
                         
                    customSwitchesMenu.append({"objects":[loopObj], "switches":loopCustomSwitch})
                    
                    for loopMenu in customSwitchesMenu[:-1]:
                        if loopObj in loopMenu["objects"] and len(loopCustomSwitch) < len(loopMenu["switches"]) and utilMod.listIntersection(loopMenu["switches"], loopCustomSwitch) == loopCustomSwitch:
                            customSwitchesMenu.pop()
                            break
                        if loopCustomSwitch == loopMenu["switches"]:
                            loopMenu["objects"].append(loopObj)
                            customSwitchesMenu.pop()
                            break
                     
                    
            for loopSwitchMenu in customSwitchesMenu:
                
                objects     = loopSwitchMenu["objects"]
                switches    = loopSwitchMenu["switches"]
                switchName  = ", ".join(list(set(utilMod.getNameSpace(objects)[1])))
                    
                if not divider and tokenCustomDivider: divider = cmds.menuItem(divider=True, parent=menu)  
  
                cmds.radioMenuItemCollection(parent=menu)
                
                newMenu         = cmds.menuItem(subMenu=True, label=switchName, parent=menu)
                radioSelected   = []
                 
                for loopCustomSwitchAttr in switches:
                    switchAttr      = loopCustomSwitchAttr.split(".")[-1]
                    objAttr         = "%s.%s"%(objects[0], switchAttr)
                    minValue        = cmds.addAttr(objAttr, query=True, minValue=True)
                    maxValue        = cmds.addAttr(objAttr, query=True, maxValue=True)
                    currValue       = cmds.getAttr(objAttr)
                    radioSelected.append((currValue == maxValue))
                    
                    cmds.menuItem(label=switchAttr, radioButton=radioSelected[-1], parent=newMenu, command=lambda x, objects=objects, switchAttr=switchAttr, switches=switches, *args:self.spaceSwitch([objects, switchAttr, switches], mode="custom"))
                
                switchAttr      = "message"
                radioSelected   = (list(set(radioSelected)) == [False])                    
                cmds.menuItem(label="None", radioButton=radioSelected, parent=newMenu, command=lambda x, objects=objects, switchAttr=switchAttr, switches=switches, *args:self.spaceSwitch([objects, switchAttr, switches], mode="custom"))
                    
                #ALL KEYS
                
                cmds.menuItem( divider=True, parent=newMenu)
                allMenu = cmds.menuItem(subMenu=True, label='All Keys', parent=newMenu) 
                radioSelected   = []
                cmds.radioMenuItemCollection(parent=menu)
                
                
                for loopCustomSwitchAttr in switches:
                    switchAttr      = loopCustomSwitchAttr.split(".")[-1]
                    objAttr         = "%s.%s"%(objects[0], switchAttr)
                    minValue        = cmds.addAttr(objAttr, query=True, minValue=True)
                    maxValue        = cmds.addAttr(objAttr, query=True, maxValue=True)
                    currValue       = cmds.getAttr(objAttr)
                    radioSelected.append((currValue == maxValue))
                    cmds.menuItem(label=switchAttr, radioButton=radioSelected[-1], parent=allMenu, command=lambda x, objects=objects, switchAttr=switchAttr, switches=switches, *args:self.spaceSwitch([objects, switchAttr, switches], all=True, mode="custom"))
                
                switchAttr      = "message"
                radioSelected   = (list(set(radioSelected)) == [False])  
                cmds.menuItem(label="None", radioButton=radioSelected, parent=allMenu, command=lambda x, objects=objects, switchAttr=switchAttr, switches=switches, *args:self.spaceSwitch([objects, switchAttr, switches], all=True, mode="custom"))
                
                #DELETE
                
                cmds.menuItem(label="Remove", parent=newMenu, command=lambda x, switches=switches, *args:self.removeCustomSwitch(switches))
Example #51
0
	def commonMenu(self):
		self.editMenu = mc.menu(label = 'Edit');
		#self.editMenuSave = mc.menuItem(
		#	label='Save Settings',
		#	command = self.editMenuSaveCmd
		#);
		#self.editMenuReset = mc.menuItem(
		#	label = 'Reset Settings',
		#	command = self.editMenuResetCmd
		#);
		self.editMenuDiv = mc.menuItem(
			d=True
		);
		self.editMenuskelRadio = mc.radioMenuItemCollection();
		self.editMenuTool = mc.menuItem(
			label = 'As Tool',
			radioButton = True,
			enable = self.supportsToolAction,
			command = self.editMenuToolCmd
		);
		#self.editMenuAction = mc.menuItem(
		#	label = 'As Action',
		#	radioButton = True,
		#	enable = self.supportsToolAction,
		#	command = self.editMenuActionCmd
		#);
		self.helpMenu = mc.menu(label = 'Help');
		self.helpMenuItem = mc.menuItem(
			label = 'Help on %s' %self.title,
			command = self.helpMenuCmd
		);
		
		mc.columnLayout(columnAttach=('both', 2), rowSpacing=4,columnWidth=340)	
		mc.text("BIPEDAL CHARACTER", align="center")
		mc.text("")
		mc.text("Step 1: Create bipedal skeleton")
		#mc.text("___________________________________")
		
		self.buttonSkelBi = mc.button(label = 'Create Skeleton', command = self.skeletonButton_B, width = 110, height = 40);
		#self.buttonSkelQuad = mc.button(label = 'Quadruped Skeleton',command = self.skeletonButton_Q, width = 120, height = 40);	
		
		mc.text("  ")
		mc.text("Step 2: Create Leg controls")
		
		mc.text("____________________________________")
		mc.text( label='LOWER BODY CONTROL', align='center' )
		
		
		
		buttonRigFootCtrl = mc.button(label = 'Legs Control',command = self.Feet_Control, width = 120, height = 40);
		buttonRigSpineCtrl = mc.button(label = 'Spine Control',command = self.Spine_Control, width = 120, height = 40,align="center");
		mc.text("  ")
		mc.text("Step 3: Create Torso/Arm controls")
		mc.text("__________________________________")
		mc.text( label='UPPER BODY CONTROL', align='center' )
		
		buttonRigArmCtrl = mc.button(label = 'Arm Control',command = self.Arm_Control, width = 120, height = 40);
		buttonRigFingersCtrl = mc.button(label = 'Fingers Control',command = self.Fingers_Control, width = 120, height = 40);
		buttonRigHeadCtrl = mc.button(label = 'Head Control', command = self.Head_Control,width=120, height=40)
		mc.text("   ")
		mc.text("Step 4: Create Master control")
		mc.text("___________________________________")
		mc.text("MASTER CONTROL",align='center')
		buttonMainCtrl = mc.button(label = 'Master Control', command = self.Master_Control, width = 120, height = 40,align='center')
		closeButton = mc.button(label = "Close", command= self.closeWindow, width = 120, height = 40,align='center')