Example #1
0
 def warnUpdate(self):
         
     if G.GT_wasUpdated:
         G.GT_wasUpdated  = None            
     
     if lastUsedVersion != VERSION:
         aToolsMod.saveInfoWithUser("userPrefs", "lastUsedVersion", VERSION)  
         G.deferredManager.sendToQueue(lambda *args:self.about(warnUpdate=True), 50, "warnUpdate")     
Example #2
0
 def warnUpdate(self):
         
     if G.GT_wasUpdated:
         G.GT_wasUpdated  = None            
     
     if lastUsedVersion != VERSION:
         aToolsMod.saveInfoWithUser("userPrefs", "lastUsedVersion", VERSION)  
         G.deferredManager.sendToQueue(lambda *args:self.about(warnUpdate=True), 50, "warnUpdate")     
Example #3
0
def install(offline=None, unistall=False):    
       
    mayaAppDir      = mel.eval('getenv MAYA_APP_DIR')
    scriptsDir      = "%s%sscripts"%(mayaAppDir, os.sep)
    userSetupFile   = scriptsDir + os.sep + "userSetup.py"  
    newUserSetup    = ""  
    
    
    try:
        with open(userSetupFile, 'r'):
            
            input = open(userSetupFile, 'r')
            lines = input.readlines()  
            
            # clear old aTool codes, if there is any
            write = True
            for n, line in enumerate(lines):        
                if line.find("# start aTools") == 0:
                    write = False
                    
                if write: newUserSetup += line
                    
                if line.find("# end aTools") == 0:
                    write = True
                    
    except IOError:
        newUserSetup    = ""       
    
    aToolCode  = "# start aTools\n\nfrom maya import cmds\nif not cmds.about(batch=True):\n\n    # launch aTools_Animation_Bar\n    cmds.evalDeferred(\"from aTools.animTools.animBar import animBarUI; animBarUI.show('launch')\", lowestPriority=True)\n\n# end aTools"    
        
    if not unistall: newUserSetup    += aToolCode
    
    # write user setup file
    output = open(userSetupFile, 'w')
    output.write(newUserSetup)
    output.close()
    
    
    if offline:        
        
        offlineFilePath = offline[0]
        createMelFile   = offline[1]
        offlineFolder   = os.sep.join(offlineFilePath.split(os.sep)[:-1])
        fileModTime     = os.path.getmtime(offlineFilePath)
        
        aToolsMod.saveInfoWithUser("userPrefs", "offlinePath", [offlineFolder, fileModTime]) 
        if createMelFile == True: createOfflineMelFile(offlineFolder, scriptsDir)
    
    
    #open tool
    if not unistall:
        from aTools.animTools.animBar import animBarUI; reload(animBarUI)
        animBarUI.show()
Example #4
0
def install(offline=None, unistall=False):

    mayaAppDir = mel.eval('getenv MAYA_APP_DIR')
    scriptsDir = "%s%sscripts" % (mayaAppDir, os.sep)
    userSetupFile = scriptsDir + os.sep + "userSetup.py"
    newUserSetup = ""

    try:
        with open(userSetupFile, 'r'):

            input = open(userSetupFile, 'r')
            lines = input.readlines()

            # clear old aTool codes, if there is any
            write = True
            for n, line in enumerate(lines):
                if line.find("# start aTools") == 0:
                    write = False

                if write: newUserSetup += line

                if line.find("# end aTools") == 0:
                    write = True

    except IOError:
        newUserSetup = ""

    aToolCode = "# start aTools\n\nfrom maya import cmds\nif not cmds.about(batch=True):\n\n    # launch aTools_Animation_Bar\n    cmds.evalDeferred(\"from aTools.animTools.animBar import animBarUI; animBarUI.show('launch')\", lowestPriority=True)\n\n# end aTools"

    if not unistall: newUserSetup += aToolCode

    # write user setup file
    output = open(userSetupFile, 'w')
    output.write(newUserSetup)
    output.close()

    if offline:

        offlineFilePath = offline[0]
        createMelFile = offline[1]
        offlineFolder = os.sep.join(offlineFilePath.split(os.sep)[:-1])
        fileModTime = os.path.getmtime(offlineFilePath)

        aToolsMod.saveInfoWithUser("userPrefs", "offlinePath",
                                   [offlineFolder, fileModTime])
        if createMelFile == True:
            createOfflineMelFile(offlineFolder, scriptsDir)

    #open tool
    if not unistall:
        from aTools.animTools.animBar import animBarUI
        reload(animBarUI)
        animBarUI.show()
Example #5
0
 def exportSets(self, *args):
     cmds.waitCursor(state=True)
     
     #currSel         = cmds.ls(selection=True) 
     self.aToolsSets = self.getaToolsSets()
     
     setsData = self.getSetsData(self.aToolsSets)
     aToolsMod.saveInfoWithUser("selectSets", "setsData", setsData)  
     
     #if len(currSel) > 0: cmds.select(currSel)
     
     cmds.waitCursor(state=False)
     cmds.warning("Select sets export done. Hit 'Import Select Sets' to import them to another scene.")
Example #6
0
 def setMultiplier(self, option):
     name = None
     for loopOption in self.multiplierValues:
         if loopOption["name"] == option:
             value = loopOption["value"]
             name  = loopOption["name"]
     
     if not name: #in case file is corrupt
         self.setMultiplier(self.defaultMultiplier)
         return
             
     self.multiplier = value
     aToolsMod.saveInfoWithUser("userPrefs", "microTransform", name)
Example #7
0
    def setMultiplier(self, option):
        name = None
        for loopOption in self.multiplierValues:
            if loopOption["name"] == option:
                value = loopOption["value"]
                name = loopOption["name"]

        if not name:  #in case file is corrupt
            self.setMultiplier(self.defaultMultiplier)
            return

        self.multiplier = value
        aToolsMod.saveInfoWithUser("userPrefs", "microTransform", name)
Example #8
0
    def exportSets(self, *args):
        cmds.waitCursor(state=True)

        #currSel         = cmds.ls(selection=True)
        self.aToolsSets = self.getaToolsSets()

        setsData = self.getSetsData(self.aToolsSets)
        aToolsMod.saveInfoWithUser("selectSets", "setsData", setsData)

        #if len(currSel) > 0: cmds.select(currSel)

        cmds.waitCursor(state=False)
        cmds.warning(
            "Select sets export done. Hit 'Import Select Sets' to import them to another scene."
        )
Example #9
0
    def copyAnimation(self, range="selected", *args):    
        cmds.waitCursor(state=True)
        
        if range == "all":
                        
            getCurves    = animMod.getAnimCurves()
            animCurves   = getCurves[0]
            animData = animMod.getAnimData(animCurves, showProgress=True)
        else:
            animData = animMod.getAnimData(showProgress=True)
            
        aToolsMod.saveInfoWithUser("copyPasteAnim", "animData", animData)  

        if cmds.window("remapNamespacesWindow", query=True, exists=True): self.remapNamespaces()
        
        cmds.waitCursor(state=False)  
Example #10
0
 def setPref(self, pref, init=False, default=False):
     
     for loopPref in PREFS:
         name    = loopPref["name"]
         if pref == name:
             command = loopPref["command"]
             if init: 
                 onOff   = self.getPref(pref)
             elif default:
                 onOff   = self.getDefPref(pref)
                 cmds.menuItem("%sMenu"%name, edit=True, checkBox=onOff)
                 aToolsMod.saveInfoWithUser("userPrefs", name, "", True) 
             else:
                 onOff   = cmds.menuItem("%sMenu"%name, query=True, checkBox=True)
                 aToolsMod.saveInfoWithUser("userPrefs", pref, onOff)
                 
             exec(command)
Example #11
0
 def setPref(self, pref, init=False, default=False):
     
     for loopPref in PREFS:
         name    = loopPref["name"]
         if pref == name:
             command = loopPref["command"]
             if init: 
                 onOff   = self.getPref(pref)
             elif default:
                 onOff   = self.getDefPref(pref)
                 cmds.menuItem("%sMenu"%name, edit=True, checkBox=onOff)
                 aToolsMod.saveInfoWithUser("userPrefs", name, "", True) 
             else:
                 onOff   = cmds.menuItem("%sMenu"%name, query=True, checkBox=True)
                 aToolsMod.saveInfoWithUser("userPrefs", pref, onOff)
                 
             exec(command)
Example #12
0
    def setHotkey(self, hotkeyDict):
        message = "Are you sure?\n\n"

        #format message
        for loopIndex, loopCommand in enumerate(hotkeyDict):

            command = loopCommand["command"]
            name = loopCommand["name"]
            key = loopCommand["hotkey"]
            alt = loopCommand["alt"]
            ctl = loopCommand["ctl"]
            q = cmds.text("query%s" % name, query=True, label=True)

            commandKeys = ""
            if ctl: commandKeys += "Ctl + "
            if alt: commandKeys += "Alt + "

            message += "%s (%s%s)" % (name, commandKeys, key)
            if q != "": message += " is assigned to: %s" % q
            message += "\n"

        confirm = cmds.confirmDialog(title='Confirm',
                                     message=message,
                                     button=['Yes', 'No'],
                                     defaultButton='Yes',
                                     cancelButton='No',
                                     dismissString='No')

        if confirm == 'Yes':
            for loopIndex, loopCommand in enumerate(hotkeyDict):

                command = loopCommand["command"]
                name = loopCommand["name"]
                key = loopCommand["hotkey"]
                alt = loopCommand["alt"]
                ctl = loopCommand["ctl"]

                cmds.nameCommand(name,
                                 command='python("%s");' % command,
                                 annotation=name)
                cmds.hotkey(k=key, alt=alt, ctl=ctl, name=name)

                aToolsMod.saveInfoWithUser("hotkeys", name, [key, alt, ctl])
                self.updateHotkeyCheck(name)

            cmds.savePrefs(hotkeys=True)
Example #13
0
 def setHotkey(self, hotkeyDict):
     message = "Are you sure?\n\n"    
     
     #format message
     for loopIndex, loopCommand in enumerate(hotkeyDict):
             
         command = loopCommand["command"]
         name    = loopCommand["name"]
         key     = loopCommand["hotkey"]
         alt     = loopCommand["alt"]
         ctl     = loopCommand["ctl"]
         q       = cmds.text("query%s"%name, query=True, label=True)
         
         commandKeys = ""
         if ctl: commandKeys += "Ctl + "
         if alt: commandKeys += "Alt + "
         
         message += "%s (%s%s)"%(name, commandKeys, key)
         if q != "": message += " is assigned to: %s"%q
         message += "\n"
         
     confirm = cmds.confirmDialog( title='Confirm', message=message, button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' )
 
     if confirm == 'Yes':    
         for loopIndex, loopCommand in enumerate(hotkeyDict):
             
             command = loopCommand["command"]
             name    = loopCommand["name"]
             key     = loopCommand["hotkey"]
             alt     = loopCommand["alt"]
             ctl     = loopCommand["ctl"]       
             
             cmds.nameCommand(name, command='python("%s");'%command, annotation=name)
             cmds.hotkey(k=key, alt=alt, ctl=ctl, name=name)
 
             aToolsMod.saveInfoWithUser("hotkeys", name, [key, alt, ctl]) 
             self.updateHotkeyCheck(name)
             
         cmds.savePrefs( hotkeys=True )
Example #14
0
 def savePrefSize(self, sizeValue):
     self.setPrefSize(sizeValue)
     aToolsMod.saveInfoWithUser("userPrefs", self.SIZE, sizeValue) 
Example #15
0
 def savePrePosRange(self, range):
     self.setPrePosRange(range)
     aToolsMod.saveInfoWithUser("userPrefs", self.PRE_POS_RANGE, range)  
Example #16
0
 def savePrefKey(self, prefKey):
     self.setPrefKey(prefKey)
     aToolsMod.saveInfoWithUser("userPrefs", self.PREF_KEY, prefKey)     
Example #17
0
 def setCameraRelativeMode(self, onOff):
     
     self.cameraRelativeMode = onOff
     
     aToolsMod.saveInfoWithUser("userPrefs", self.CAMERA_KEY, onOff)
     self.refreshViewports()
Example #18
0
 def savePrefKey(self, prefKey):
     self.setPrefKey(prefKey)
     aToolsMod.saveInfoWithUser("userPrefs", self.PREF_KEY, prefKey)
Example #19
0
 def removeCustomSwitch(self, switch):
     allCustomSwitch     = aToolsMod.loadInfoWithUser("spaceSwitch", "customSwitch") or []
     
     allCustomSwitch.remove(switch)
     aToolsMod.saveInfoWithUser("spaceSwitch", "customSwitch", allCustomSwitch)
Example #20
0
 def saveLastState(self, state=True):
     aToolsMod.saveInfoWithUser("userPrefs", "animationBarLastState", state)
Example #21
0
 def savePrefSize(self, sizeValue):
     self.setPrefSize(sizeValue)
     aToolsMod.saveInfoWithUser("userPrefs", self.SIZE, sizeValue)
Example #22
0
 def savePrePosRange(self, range):
     self.setPrePosRange(range)
     aToolsMod.saveInfoWithUser("userPrefs", self.PRE_POS_RANGE, range)
Example #23
0
    def setColoredKeys(self, onOff):
        onOff = not self.getColoredKeys()

        G.TM_coloredKeys = onOff

        aToolsMod.saveInfoWithUser("userPrefs", "coloredKeys", onOff)
Example #24
0
    def setCameraRelativeMode(self, onOff):

        self.cameraRelativeMode = onOff

        aToolsMod.saveInfoWithUser("userPrefs", self.CAMERA_KEY, onOff)
        self.refreshViewports()
Example #25
0
 def saveLastState(self, state=True):
     aToolsMod.saveInfoWithUser("userPrefs", "animationBarLastState", state)
Example #26
0
    def setColoredKeys(self, onOff):
        onOff = not self.getColoredKeys()

        G.TM_coloredKeys = onOff

        aToolsMod.saveInfoWithUser("userPrefs", "coloredKeys", onOff)
Example #27
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 #28
0
    def dontShowAgain(self, onOff):

        aToolsMod.saveInfoWithUser("userPrefs", "dontShowAnimBotWarningAgain",
                                   onOff)