Пример #1
0
    def removeCustomSwitch(self, switch):
        allCustomSwitch = aToolsMod.loadInfoWithUser("spaceSwitch",
                                                     "customSwitch") or []

        allCustomSwitch.remove(switch)
        aToolsMod.saveInfoWithUser("spaceSwitch", "customSwitch",
                                   allCustomSwitch)
Пример #2
0
    def warnUpdate(self):
        return

        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")
Пример #3
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)
Пример #4
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."
        )
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
0
    def setColoredKeys(self, onOff):
        onOff = not self.getColoredKeys()

        G.TM_coloredKeys = onOff

        aToolsMod.saveInfoWithUser("userPrefs", "coloredKeys", onOff)
Пример #9
0
 def savePrefSize(self, sizeValue):
     self.setPrefSize(sizeValue)
     aToolsMod.saveInfoWithUser("userPrefs", self.SIZE, sizeValue)
Пример #10
0
 def savePrePosRange(self, range):
     self.setPrePosRange(range)
     aToolsMod.saveInfoWithUser("userPrefs", self.PRE_POS_RANGE, range)
Пример #11
0
 def savePrefKey(self, prefKey):
     self.setPrefKey(prefKey)
     aToolsMod.saveInfoWithUser("userPrefs", self.PREF_KEY, prefKey)
Пример #12
0
    def setCameraRelativeMode(self, onOff):

        self.cameraRelativeMode = onOff

        aToolsMod.saveInfoWithUser("userPrefs", self.CAMERA_KEY, onOff)
        self.refreshViewports()
Пример #13
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))