Esempio n. 1
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) 
Esempio n. 2
0
 def populateMenu(self, menu, *args):
                 
     uiMod.clearMenuItems(menu)  
     
     if self.copyCache != []: 
         cmds.menuItem(label='Copy', command=self.copy, parent=menu)
         cmds.menuItem(label='Paste to All Frames' , command=lambda *args: self.paste('allFrames'), parent=menu)            
         cmds.menuItem(divider=True, parent=menu)    
     
     
     cmds.menuItem(label='Copy Relative to World' , command=self.copyWorld, parent=menu)  
Esempio n. 3
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)
Esempio n. 4
0
 def populateDuplicateButtonMenu(self, menu, selSet, colorName):
     
     outputNameSpaces    = utilMod.listAllNamespaces()
             
     uiMod.clearMenuItems(menu)
     if not outputNameSpaces: return
             
     for loopNameSpace in outputNameSpaces:
         newMenu = cmds.menuItem(subMenu=True, label=loopNameSpace, parent=menu)
         for loopColor in self.colors:                
             loopColorName  = loopColor["name"]
             
             if colorName != loopColorName:
                 cmds.menuItem(label=utilMod.toTitle(loopColorName), parent=newMenu, command=lambda x, loopNameSpace=loopNameSpace, loopColorName=loopColorName, *args:self.duplicateSet(selSet,loopNameSpace,loopColorName))
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
0
    def populateDuplicateButtonMenu(self, menu, selSet, colorName):

        outputNameSpaces = utilMod.listAllNamespaces()

        uiMod.clearMenuItems(menu)
        if not outputNameSpaces: return

        for loopNameSpace in outputNameSpaces:
            newMenu = cmds.menuItem(subMenu=True,
                                    label=loopNameSpace,
                                    parent=menu)
            for loopColor in self.colors:
                loopColorName = loopColor["name"]

                if colorName != loopColorName:
                    cmds.menuItem(
                        label=utilMod.toTitle(loopColorName),
                        parent=newMenu,
                        command=lambda x, loopNameSpace=loopNameSpace,
                        loopColorName=loopColorName, *args: self.duplicateSet(
                            selSet, loopNameSpace, loopColorName))
Esempio n. 8
0
 def populateaToolsMenu(self, menu, button, *args):
     
     #print menu
     #print button
     #menu = menu[0]
     
     uiMod.clearMenuItems(menu)
     
     shortPrefs =    PREFS[:4]
     for loopPref in shortPrefs:
         name    = loopPref["name"]
         cmds.menuItem('%sMenu'%name, label=utilMod.toTitle(name), command=lambda x, name=name, *args: self.setPref(name), checkBox=self.getPref(name), parent=menu)
     
     #ANIMATION CRASH RECOVERY      
     animationCrashRecoveryPref =    PREFS[4]
     cmds.menuItem("animationCrashRecoveryMenu", label='Animation Crash Recovery' , command=lambda *args: self.setPref(animationCrashRecoveryPref["name"]), checkBox=self.getPref(animationCrashRecoveryPref["name"]), parent=menu)
     cmds.menuItem(optionBox=True, command=animationCrashRecovery.optionBoxWindow, parent=menu)
     
     cmds.menuItem(divider=True, parent=menu)
     
     subMenu = cmds.menuItem("prefsMenu", subMenu=True, label='Preferences' , tearOff=True, parent=menu)
     
     self.commandsAndHotkeys      = CommandsAndHotkeys()
     cmds.menuItem(label="Commands and Hotkeys",         command=self.commandsAndHotkeys.openGui, parent=subMenu)
     cmds.menuItem(divider=True, parent=subMenu)
     shortPrefs =    PREFS[5:]
     for loopPref in shortPrefs:
         name    = loopPref["name"]
         cmds.menuItem('%sMenu'%name,            label=utilMod.toTitle(name),        command=lambda x, name=name, *args: self.setPref(name), checkBox=self.getPref(name), parent=subMenu)
     
     cmds.menuItem(divider=True, parent=subMenu)
     cmds.menuItem("loadDefaultsMenu",          label="Load Defaults",     command=self.loadDefaultPrefs, parent=subMenu)
     
     cmds.menuItem("shelfButtonMenu",          label="Create Toggle on Shelf",           command=shelfButton, parent=menu)
     cmds.menuItem(                            label="Refresh", command=refreshATools, parent=menu)
     cmds.menuItem(                            label="Uninstall", command=self.uninstall, parent=menu)
     cmds.menuItem( divider=True )
     cmds.menuItem(                            label="Help", command=self.help, parent=menu)
     cmds.menuItem(                            label="About", command=self.about, parent=menu)
Esempio n. 9
0
 def populateaToolsMenu(self, menu, button, *args):
     
     #print menu
     #print button
     #menu = menu[0]
     
     uiMod.clearMenuItems(menu)
     
     shortPrefs =    PREFS[:4]
     for loopPref in shortPrefs:
         name    = loopPref["name"]
         cmds.menuItem('%sMenu'%name, label=utilMod.toTitle(name), command=lambda x, name=name, *args: self.setPref(name), checkBox=self.getPref(name), parent=menu)
     
     #ANIMATION CRASH RECOVERY      
     animationCrashRecoveryPref =    PREFS[4]
     cmds.menuItem("animationCrashRecoveryMenu", label='Animation Crash Recovery' , command=lambda *args: self.setPref(animationCrashRecoveryPref["name"]), checkBox=self.getPref(animationCrashRecoveryPref["name"]), parent=menu)
     cmds.menuItem(optionBox=True, command=animationCrashRecovery.optionBoxWindow, parent=menu)
     
     cmds.menuItem(divider=True, parent=menu)
     
     subMenu = cmds.menuItem("prefsMenu", subMenu=True, label='Preferences' , tearOff=True, parent=menu)
     
     self.commandsAndHotkeys      = CommandsAndHotkeys()
     cmds.menuItem(label="Commands and Hotkeys",         command=self.commandsAndHotkeys.openGui, parent=subMenu)
     cmds.menuItem(divider=True, parent=subMenu)
     shortPrefs =    PREFS[5:]
     for loopPref in shortPrefs:
         name    = loopPref["name"]
         cmds.menuItem('%sMenu'%name,            label=utilMod.toTitle(name),        command=lambda x, name=name, *args: self.setPref(name), checkBox=self.getPref(name), parent=subMenu)
     
     cmds.menuItem(divider=True, parent=subMenu)
     cmds.menuItem("loadDefaultsMenu",          label="Load Defaults",     command=self.loadDefaultPrefs, parent=subMenu)
     
     cmds.menuItem("shelfButtonMenu",          label="Create Toggle on Shelf",           command=shelfButton, parent=menu)
     cmds.menuItem(                            label="Refresh", command=refreshATools, parent=menu)
     cmds.menuItem(                            label="Uninstall", command=self.uninstall, parent=menu)
     cmds.menuItem( divider=True )
     cmds.menuItem(                            label="Help", command=self.help, parent=menu)
     cmds.menuItem(                            label="About", command=self.about, parent=menu)
Esempio n. 10
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)
Esempio n. 11
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))
Esempio n. 12
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)