本文整理匯總了Python中maya.cmds.internalVar方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.internalVar方法的具體用法?Python cmds.internalVar怎麽用?Python cmds.internalVar使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.cmds
的用法示例。
在下文中一共展示了cmds.internalVar方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import internalVar [as 別名]
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 []
示例2: userPrefDir
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import internalVar [as 別名]
def userPrefDir():
return cmds.internalVar(userPrefDir=True)
示例3: get_data_folder
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import internalVar [as 別名]
def get_data_folder():
from maya import cmds
return cmds.internalVar(userPrefDir=True)
示例4: loadConfig
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import internalVar [as 別名]
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
示例5: save
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import internalVar [as 別名]
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
示例6: exportControl
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import internalVar [as 別名]
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