Python maya.cmds 模块,internalVar() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用maya.cmds.internalVar()

项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def loadValues(*args):
    """loads the saved path file, if there is one"""
    #check if file exists
    try:
        userDir = cmds.internalVar(upd=True) + "zbw_appendPathSave.txt"
        file = open(userDir, "r")
        paths = []
        #read values from file to list
        for line in file:
            paths.append(line.rstrip("\n"))
        file.close()

        #replace tfbg's with those values
        cmds.textFieldButtonGrp(widgets["path1"], e=True, tx=paths[0])
        cmds.textFieldButtonGrp(widgets["path2"], e=True, tx=paths[1])
        cmds.textFieldButtonGrp(widgets["path3"], e=True, tx=paths[2])
    except IOError:
        cmds.warning("You don't seem to have a 'zbw_appendPathSave.txt' file saved in your user prefs dir")
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def saveValues(*args):
    """saves the current path fields to a file in your user pref directory. Files is called 'zbw_appendPath.txt'"""

    path1 = cmds.textFieldButtonGrp(widgets["path1"], q=True, tx=True) + "\n"
    path2 = cmds.textFieldButtonGrp(widgets["path2"], q=True, tx=True) + "\n"
    path3 = cmds.textFieldButtonGrp(widgets["path3"], q=True, tx=True) + "\n"

    #write to file
    userDir = cmds.internalVar(upd=True) + "zbw_appendPathSave.txt"
    file = open(userDir, "w")

    file.write(path1)
    file.write(path2)
    file.write(path3)

    file.close()
项目:pipeline    作者:liorbenhorin    | 项目源码 | 文件源码
def userPrefDir():
    return cmds.internalVar(userPrefDir=True)
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def getScripts(*args):

    #### here we should search all possible places, create a separate tab for each location (folder name?)

    #get the script path
    usd = cmds.internalVar(usd=True)
    print usd
    #get list of files there
    fls = os.listdir(usd)
    fls.sort()

########### check whether the thing is a folder or not, should really just sort for .mel and .py, not exclude as I'm doing
########### sort files (by name)
    counter = 1
    for fl in fls:
        print fl
        if (fl.rpartition(".")[2] != "pyc") and (fl[-1] != "~"):
            #if not in our dictionary, color it red
            if (fl.rpartition(".")[0] in pythonRun):
                cmds.textScrollList(widgets["list"], e=True, a=fl, lf = (counter, "boldLabelFont"))

            elif (fl.rpartition(".")[2] == "mel"): 
                cmds.textScrollList(widgets["list"], e=True, a=fl, lf = (counter, "boldLabelFont"))

            else:
                #print "%s doesn't have its' shit together"%fl
                cmds.textScrollList(widgets["list"], e=True, a=fl, lf = (counter, "smallObliqueLabelFont"))

            counter +=1
项目:zTools    作者:zethwillie    | 项目源码 | 文件源码
def customUI(self):
        cmds.text("put UI stuff here for options")
        path = cmds.internalVar(upd=True) + "default.txt"
        self.widgets["destinationTFBG"] = cmds.textFieldButtonGrp(l="destination", bl="<<<", cal=([1,"left"], [2,"left"], [3,"left"]), cw3=(65,275, 50), tx=path, bc=self.getLocation)
项目:deltaMushToSkinCluster    作者:jeanim    | 项目源码 | 文件源码
def main():
    createModFile()
    pluginsPrefsPath = cmds.internalVar(upd=True)+'pluginPrefs.mel'
    enableaPlugin(filename=pluginsPrefsPath)
    createShelfBtn()
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
def exportControl(curves, name):
    '''Export a control curve
    '''

    if not isinstance(curves, (list, tuple)):
        curves = [curves]

    grp = mc.group(em=True, name=name)

    for each in curves:
        ml_parentShape.parentShape(each, grp)

    mc.delete(grp, constructionHistory=True)

    tempFile = mc.internalVar(userTmpDir=True)
    tempFile+='tempControlExport.ma'

    mc.select(grp)
    mc.file(tempFile, force=True, typ='mayaAscii', exportSelected=True)

    with open(tempFile, 'r') as f:
        contents = f.read()

    ctrlLines = ['//ML Control Curve: '+name]

    record = False
    for line in contents.splitlines():
        if line.startswith('select'):
            break
        if line.strip().startswith('rename'): #skip the uuid commands
            continue
        if line.startswith('createNode transform'):
            record = True
            ctrlLines.append('string $ml_tempCtrlName = `createNode transform -n "'+name+'_#"`;')
        elif line.startswith('createNode nurbsCurve'):
            ctrlLines.append('createNode nurbsCurve -p $ml_tempCtrlName;')
        elif record:
            ctrlLines.append(line)


    with open(controlFilePath(name), 'w') as f:
        f.write('\n'.join(ctrlLines))

    return grp