本文整理汇总了Python中maya.cmds.internalVar函数的典型用法代码示例。如果您正苦于以下问题:Python internalVar函数的具体用法?Python internalVar怎么用?Python internalVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了internalVar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mayaTools
def mayaTools():
#import custom maya setup script
print cmds.internalVar(usd = True)
print cmds.internalVar(upd = True)
path = cmds.internalVar(usd = True)
path = path + "mayaTools.txt"
print path
if os.path.exists(path):
f = open(path, 'r')
mayaToolsDir = f.readline()
if not os.path.exists(mayaToolsDir):
mayaToolsInstall_UI()
path = mayaToolsDir + "/General/Scripts"
pluginPath = mayaToolsDir + "/General/Plugins"
#look in sys.path to see if path is in sys.path. if not, add it
if not path in sys.path:
sys.path.append(path)
#run setup
import customMayaMenu as cmm
cmm.customMayaMenu()
cmds.file(new = True, force = True)
else:
mayaToolsInstall_UI()
示例2: setupScriptPaths
def setupScriptPaths():
"""
Add Maya-specific directories to sys.path
"""
# Extra libraries
#
try:
# Tkinter libraries are included in the zip, add that subfolder
p = [p for p in sys.path if p.endswith('.zip')][0]
sys.path.append( os.path.join(p,'lib-tk') )
except:
pass
# Per-version prefs scripts dir (eg .../maya8.5/prefs/scripts)
#
prefsDir = cmds.internalVar( userPrefDir=True )
sys.path.append( os.path.join( prefsDir, 'scripts' ) )
# Per-version scripts dir (eg .../maya8.5/scripts)
#
scriptDir = cmds.internalVar( userScriptDir=True )
sys.path.append( os.path.dirname(scriptDir) )
# User application dir (eg .../maya/scripts)
#
appDir = cmds.internalVar( userAppDir=True )
sys.path.append( os.path.join( appDir, 'scripts' ) )
示例3: loadConfig
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:
f = open(configFilePath, 'r')
extra_config = json.load(f)
additionalPaths = extra_config["path"]
f.close()
except IOError:
print("Failed to load config file")
config.extend(additionalPaths)
return config
示例4: __init__
def __init__(self):
# scripts
scriptDir = cmds.internalVar(usd=1)
scriptDir = scriptDir.partition('maya')
scriptDir = os.path.join(scriptDir[0], scriptDir[1])
self.rootPath = os.path.join(scriptDir, 'scripts')
# prefs
prefDir = cmds.internalVar(upd=1)
# build paths
self.iconPath = os.path.join(prefDir, 'icons')
self.iconOn = os.path.join(self.iconPath, 'srv_mirSel_on_icon.xpm')
self.iconOff = os.path.join(self.iconPath, 'srv_mirSel_off_icon.xpm')
self.pairPath = os.path.join(self.rootPath, 'pairSelectList.txt')
示例5: setCurrentProject
def setCurrentProject(projectName, *args):
#get access to maya tools path
toolsPath = cmds.internalVar(usd = True) + "mayaTools.txt"
if os.path.exists(toolsPath):
f = open(toolsPath, 'r')
mayaToolsDir = f.readline()
f.close()
#re-write settings
if os.path.exists(mayaToolsDir + "/General/Scripts/projectSettings.txt"):
f = open(mayaToolsDir + "/General/Scripts/projectSettings.txt", 'r')
oldSettings = cPickle.load(f)
useSourceControl = oldSettings.get("UseSourceControl")
f.close()
#write out new settings
settings = {}
settings["UseSourceControl"] = useSourceControl
settings["CurrentProject"] = projectName
f = open(mayaToolsDir + "/General/Scripts/projectSettings.txt", 'w')
cPickle.dump(settings, f)
f.close()
示例6: saveCopy
def saveCopy(self, data):
"Button callback to end the dialog"
resName = self.currentResource
if resName is None:
return
ext = os.path.splitext(resName)[1]
if ext == '':
ext = '.png'
# Bring a file browser to select where to save the copy
captionStr = stringTable['y_resourceBrowser.kPickIconCaption']
iconDir = cmds.internalVar(userBitmapsDir=True)
fileList = cmds.fileDialog2(caption=captionStr,
fileMode=0,
okCaption=captionStr,
fileFilter='*' + ext,
startingDirectory=iconDir)
path = None
if fileList is not None:
if len(fileList) > 0 and fileList[0] != "":
path = fileList[0]
if path is not None:
cmds.resourceManager(saveAs=(resName, path))
示例7: override_panels
def override_panels(custom_hs_cmd=None, custom_ne_cmd=None):
# check if icons is in maya resources, if not, copy into userBitmapsDir
user_icons_path = cmds.internalVar(userBitmapsDir=True)
mtt_icons_path = os.path.join(os.path.dirname(__file__), 'icons')
maya_icons = os.listdir(user_icons_path)
for ico in MTT_ICONS_NAME:
if ico not in maya_icons:
source_file = os.path.join(mtt_icons_path, ico)
destination_file = os.path.join(user_icons_path, ico)
shutil.copy2(source_file, destination_file)
# create MEL global proc
cmd = mel.createMelWrapper(
override_add_hypershade_panel, types=['string'], returnCmd=True)
mel.eval(cmd)
cmd = mel.createMelWrapper(
override_add_node_editor_panel, types=['string'], returnCmd=True)
mel.eval(cmd)
# edit callback of scripted panel
cmds.scriptedPanelType(
'hyperShadePanel', edit=True,
addCallback='override_add_hypershade_panel')
cmds.scriptedPanelType(
'nodeEditorPanel', edit=True,
addCallback='override_add_node_editor_panel')
# store custom cmd
if custom_hs_cmd:
cmds.optionVar(sv=[VAR_HS_CMD, custom_hs_cmd])
if custom_ne_cmd:
cmds.optionVar(sv=[VAR_NE_CMD, custom_hs_cmd])
示例8: setupTools
def setupTools():
path = cmds.internalVar(usd = True) + "mayaTools.txt"
f = open(path, 'r')
mayaToolsDir = f.readline()
path = mayaToolsDir + "/General/Scripts"
pluginPath = mayaToolsDir + "/General/Plugins"
#look in sys.path to see if path is in sys.path. if not, add it
if not path in sys.path:
sys.path.append(path)
#make sure MAYA_PLUG_IN_PATH has our plugin path
pluginPaths = os.environ["MAYA_PLUG_IN_PATH"]
pluginPaths = pluginPaths + ";" + pluginPath
os.environ["MAYA_PLUG_IN_PATH"] = pluginPaths
#setup menu item in main window
import customMayaMenu as cmm
cmm.customMayaMenu()
示例9: defaultPath
def defaultPath():
# user = os.path.expanduser('~')
# mainDir = user + '/maya/characterSets/'
# proper directory query
varPath = cmds.internalVar(userAppDir=True)
mainDir = os.path.join(varPath, 'characterSets')
return mainDir
示例10: UI
def UI():
# check to see if the window exists
if cmds.window('exampleUI', exists = True):
cmds.deleteUI('exampleUI')
#create the window
window = cmds.window('exampleUI', title = 'exampleUI', w = 300, h = 300, mnb = False, mxb = False, sizeable = False)
#show window
cmds.showWindow(window)
# create a main layout
mainLayout = cmds.columnLayout(h = 300, w = 300)
# banner image
imagePath = cmds.internalVar(userPrefDir = True) + 'icons' + '/test.jpg' # find the path to the image
cmds.image(w = 300, h = 100, image = imagePath)
cmds.separator(h = 15)# just a seperator
# projects option menu
projectsOptionMenu = cmds.optionMenu ( 'projectsOptionMenu', width = 300, changeCommand = populateCharacters, label = 'choose a project: ') # change command needed to update character option menu based on what project is selected
# create a character option menu
characerOptionMenu = cmds.optionMenu ( 'characerOptionMenu', width = 300, label = 'choose a character: ')
cmds.separator(h = 15) # just a seperator
# create the build button
cmds.button(label = 'build', w = 300, h = 50 ,c = build)
# activate populate projects option menu
populateProjects()
# activate populate characaters option menu
populateCharacters()
示例11: __init__
def __init__(self):
self.userDir=os.path.expanduser("~")
self.fileFilters=["ma","jpg","png","mb",'iff','tga','tif','PNG','JPG']
self.userName=os.path.basename(self.userDir)
self.minimeDir=os.path.normpath(os.path.join(self.userDir,"MiniMe"))
self.favFile=os.path.join(self.minimeDir,"favorites.txt")
self.ftpData= os.path.normpath(os.path.join(self.minimeDir,"ftp.db"))
try:
self.prjDir = (cmds.workspace(fn=True)).replace("/","\\") #returns project directory for start up
self.defaultImage = cmds.internalVar(usd=True)+"notFound.jpg" # get path of image from script directory
except Exception as e:
print e
##Check the MiniME setting folder exist if not create one then check
## if Favorite file exist if not create it, if it exist read it.
if os.path.isdir(self.minimeDir):
### "Mini Me Setting Directory Exist or not"
if os.path.isfile(self.favFile):
### "Favorite file exists"
try:
read_fav_file=open(self.favFile,"r")
### Load favorite dictioary from file
self.favItems=eval(read_fav_file.read())
if self.favItems is None:
print "No favorites found in file."
except Exception as err:
self.favItems={}
print err
finally:
read_fav_file.close()
else:
self.createFavFile()
else:
print "Creating " + self.minimeDir
os.mkdir(self.minimeDir)
示例12: getSettings
def getSettings(appName, unique=False, version=None):
"""
Helper to get a settings object for a given app-name
It uses INI settings format for Maya, and registry format for stand-alone tools.
Try to ensure that the appName provided is unique, as overlapping appNames
will try to load/overwrite each others settings file/registry data.
:param appName: string -- Application name to use when creating qtSettings ini file/registry entry.
:return: QtCore.QSettings -- Settings object
"""
ukey = __name__ + '_QSettings'
if not unique and (appName, version) in __main__.__dict__.setdefault(__name__+'_settings', {}):
return __main__.__dict__[ukey][(appName, version)]
if has_maya:
settingsPath = os.path.join(cmds.internalVar(upd=True), 'mlib_settings', appName+'.ini')
settingsPath = os.path.normpath(settingsPath)
settings = QtCore.QSettings(settingsPath, QtCore.QSettings.IniFormat)
settings.setParent(getMayaWindow())
else:
settings = QtCore.QSettings('MLib', appName)
if not unique:
__main__.__dict__[ukey][(appName, version)] = settings
elif isinstance(unique, QtCore.QObject):
settings.setParent(unique)
if version is not None:
if float(settings.value('__version__', version))<version:
settings.clear()
settings.setValue('__version__', version)
return settings
示例13: TappInstall_browse
def TappInstall_browse(*args):
repoPath=cmds.fileDialog2(dialogStyle=1,fileMode=3)
if repoPath:
repoPath=repoPath[0].replace('\\','/')
check=False
#checking all subdirectories
for name in os.listdir(repoPath):
#confirm that this is the Tapp directory
if name=='Tapp':
check=True
if check:
#create the text file that contains the Tapp directory path
path=cmds.internalVar(upd=True)+'Tapp.yml'
f=open(path,'w')
data='{launchWindowAtStartup: False, repositoryPath: \''+repoPath+'\'}'
f.write(data)
f.close()
#run setup
sys.path.append(repoPath)
cmds.evalDeferred('import Tapp')
#delete ui
cmds.deleteUI('TappInstall_UI')
else:
cmds.warning('Selected directory is not the \'Tapp\' directory. Please try again')
示例14: skinWeights
def skinWeights(x=None, export=None, f=None, fileName=None):
# Import/export skin weights from/to a file
# x/export: 0 for import, 1 for export
# f/fileName: filename under default project directory
x = x or export
if not (f or fileName):
raise Exception, "Missing argument: fileName"
if fileName:
f = fileName
obj = cmds.ls(sl=1)
if not obj:
raise Exception, "No object selected"
obj = obj[0]
node = None
for n in cmds.listHistory(obj, f=0, bf=1):
if cmds.nodeType(n) == 'skinCluster':
node = n
break
if not node:
raise Exception, "no skin cluster found"
mode = "r"
if x:
mode = "w"
f = open(cmds.internalVar(uwd=1) + f, mode)
allTransforms = cmds.skinPercent(node, cmds.ls(cmds.polyListComponentConversion(obj, tv=1), fl=1), q=1, t=None)
for vertex in cmds.ls(cmds.polyListComponentConversion(obj,tv=1), fl=1):
if x:
transforms = cmds.skinPercent(node, vertex, ib=1e-010, q=1, t=None)
weights = cmds.skinPercent(node, vertex, ib=1e-010, q=1, v=1)
s = ""
for i in range(len(transforms)):
s += str(weights[i])+"@"+transforms[i]+" "
f.write(s+"\n")
else:
weights = {}
for t in allTransforms:
weights[t] = float(0)
readWeights = f.readline().strip().split(" ")
for i in readWeights:
w = i.split("@")
if w[1] in weights:
weights[w[1]] = float(w[0])
w = []
for i in weights.iteritems():
w.append(i)
cmds.skinPercent(node, vertex, tv=w)
f.close()
示例15: initUI
def initUI(self):
comboBox = QtGui.QComboBox()
# comboBox.set
# set directory for cookie images
directory = mc.internalVar(uad=True) + "scripts/assets/cookie/"
# save list of images in directory
images = os.listdir(directory)
# remove DS_Store
images.pop(0)
# populate combo box with image names
comboBox.addItems(images)
self.mainLayout.addWidget(comboBox)
# make image preview area
# make a create button
create_btn = QtGui.QPushButton("Create")
# connect button's click slot to create_cookie method
create_btn.clicked.connect(self.create_cookie)
# add the button to the main layout
self.mainLayout.addWidget(create_btn)
# make a create button
replace_btn = QtGui.QPushButton("Replace")
# connect button's click slot to create_cookie method
replace_btn.clicked.connect(self.replace_cookie)
# add the button to the main layout
self.mainLayout.addWidget(replace_btn)