Python maya.cmds.internalVar() Examples

The following are 6 code examples of maya.cmds.internalVar(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: Rush.py    From rush with MIT License 6 votes vote down vote up
def read(cls):
        """ Load history

        Return:
            history(list): list of commands

        """

        mayaScriptDir = cmds.internalVar(userScriptDir=True)
        historyPath = os.path.join(mayaScriptDir, "rushHistory.txt")
        if os.path.exists(historyPath):
            try:
                historyFile = open(historyPath, 'r')
                history = historyFile.read().splitlines()
                historyFile.close()
                return history
            except IOError:
                return []
        else:
            return [] 
Example #2
Source File: maya_warpper.py    From pipeline with MIT License 5 votes vote down vote up
def userPrefDir():
    return cmds.internalVar(userPrefDir=True) 
Example #3
Source File: applications.py    From hotbox_designer with BSD 3-Clause Clear License 5 votes vote down vote up
def get_data_folder():
        from maya import cmds
        return cmds.internalVar(userPrefDir=True) 
Example #4
Source File: __init__.py    From rush with MIT License 5 votes vote down vote up
def loadConfig():
    """ Load config file

    Return:
        config(list): List of path module paths

    """
    configFilePath = os.path.normpath(os.path.join(
        cmds.internalVar(userScriptDir=True), 'rush.json'))

    defaultModulePath = os.path.normpath(os.path.join(
        cmds.internalVar(userScriptDir=True), 'rush', 'module'))

    config = [defaultModulePath]

    # Use only default module path if config file does not exist
    if not os.path.exists(configFilePath):
        print("Additional config file not found: %s" % configFilePath)
        return config

    # Open and load config file in use home dir and append it to the
    # config list
    try:
        fileData = open(configFilePath, 'r')
        extraConfig = json.load(fileData)
        additionalPaths = extraConfig["path"]
        fileData.close()
    except IOError:
        print("Failed to load config file")

    config.extend(additionalPaths)

    return config 
Example #5
Source File: Rush.py    From rush with MIT License 5 votes vote down vote up
def save(self):
        """ Write history

        """

        mayaScriptDir = cmds.internalVar(userScriptDir=True)
        historyPath = os.path.join(mayaScriptDir, "rushHistory.txt")
        try:
            historyFile = open(historyPath, 'w')
            for line in self.history:
                historyFile.write(line + "\n")
            historyFile.close()
        except IOError:
            pass 
Example #6
Source File: ml_controlLibrary.py    From ml_tools with MIT License 4 votes vote down vote up
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