# -*- coding: utf-8 -*-
from PySide2 import QtCore
from PySide2 import QtGui
from shiboken2 import wrapInstance
import pyside2uic
import xml.etree.ElementTree as xml
from cStringIO import StringIO
import maya.cmds as cmds
import maya.OpenMayaUI as mui
import maya.mel as mel
import os, glob, math, re, sys, time
def setEnvPath():
aboutValue = cmds.about(v=True)
if '2014' in aboutValue:
aboutValueName = '2014'
elif '2015' in aboutValue:
aboutValueName = '2015'
elif '2016' in aboutValue:
aboutValueName = '2016'
elif '2013' in aboutValue:
aboutValueName = '2013'
elif '2012' in aboutValue:
aboutValueName = '2012'
else:
aboutValueName = aboutValue
################################################################################
pathNameList = {'MAYA_SCRIPT_PATH':'scriptPathLsit', 'MAYA_SHELF_PATH':'shelfPathList',
'XBMLANGPATH':'XBMLANGPathList', 'PYTHONPATH':'pythonPathList',
'MAYA_PLUG_IN_PATH':'pluginPathLsit'}
scriptDir = cmds.internalVar(usd=True)
aboutDir = os.path.abspath(os.path.join(os.path.dirname(scriptDir), os.path.pardir))
scriptPathLsit = [scriptDir[:-1], r'F:/Reference/TD/maya2017/tool_scripts', r'F:/Reference/TD/maya2017/scripts']
shelfPathList = [aboutDir+r'\prefs\shelves', r'F:/Reference/TD/maya2017/tool_scripts', r'F:/Reference/TD/maya2017/scripts']
XBMLANGPathList = [aboutDir+r'\prefs\icons', r'F:/Reference/TD/maya2017/tool_scripts/icons', r'F:/Reference/TD/maya2017/icons']
pythonPathList = [r'F:/Reference/TD/maya2017/tool_scripts', r'F:/Reference/TD/maya2017', r'F:/Reference/TD/maya2017/imagesQrc']
pluginPathLsit = [r'F:/Reference/TD/maya2017/plugins/'+aboutValueName]
################################################################################
if os.path.exists(aboutDir+'/Maya.env'):
fileName = open(aboutDir+'/Maya.env', 'r')
try:
all_lines = fileName.readlines()
fileName.close()
if all_lines:
##################
pathKeyList = pathNameList.keys()
editPathList = []
for index in range(len(all_lines)):
oldString = all_lines[index].strip()
linePath = oldString.split('=')[0].strip()
if linePath in pathKeyList:
addString = ''
for pathValue in eval(pathNameList[linePath]):
if not (pathValue in oldString):
addString = addString + ';' + pathValue
if addString:
if oldString.endswith(';'):
all_lines[index] = oldString[:-1] + addString + ';\r\n'
else:
all_lines[index] = oldString + addString + ';\r\n'
editPathList.append(linePath)
##################
for pathKey in pathKeyList:
if not (pathKey in editPathList):
all_lines.append('\r\n' + pathKey + ' = ' + ';'.join(eval(pathNameList[pathKey])) + ';')
##################
fileName = open(aboutDir+'/Maya.env', 'w')
fileName.truncate()
fileName.writelines(all_lines)
fileName.close()
##################
else:
fileName = open(aboutDir+'/Maya.env', 'w')
fileName.write('MAYA_SCRIPT_PATH = ')
for a in range(len(scriptPathLsit)):
fileName.write(scriptPathLsit[a]+';')
fileName.write('\r\n')
#############################
fileName.write('MAYA_SHELF_PATH = ')
for a in range(len(shelfPathList)):
fileName.write(shelfPathList[a]+';')
fileName.write('\r\n')
#############################
fileName.write('XBMLANGPATH = ')
for a in range(len(XBMLANGPathList)):
fileName.write(XBMLANGPathList[a]+';')
fileName.write('\r\n')
#############################
fileName.write('PYTHONPATH = ')
for a in range(len(pythonPathList)):
fileName.write(pythonPathList[a]+';')
fileName.write('\r\n')
#############################
fileName.write('MAYA_PLUG_IN_PATH = ')
for a in range(len(pluginPathLsit)):
fileName.write(pluginPathLsit[a]+';')
fileName.write('\r\n')
#############################
fileName.close()
#############################
cmds.confirmDialog(t=u'提示!', m=u'插件已经安装完成,重启maya后即可使用!', b='OK', db='OK', cb='OK', ds='OK')
finally:
fileName.close()
else:
fileName = open(aboutDir+'/Maya.env', 'w')
#############################
try:
fileName.write('MAYA_SCRIPT_PATH = ')
for a in range(len(scriptPathLsit)):
fileName.write(scriptPathLsit[a]+';')
fileName.write('\r\n')
#############################
fileName.write('MAYA_SHELF_PATH = ')
for a in range(len(shelfPathList)):
fileName.write(shelfPathList[a]+';')
fileName.write('\r\n')
#############################
fileName.write('XBMLANGPATH = ')
for a in range(len(XBMLANGPathList)):
fileName.write(XBMLANGPathList[a]+';')
fileName.write('\r\n')
#############################
fileName.write('PYTHONPATH = ')
for a in range(len(pythonPathList)):
fileName.write(pythonPathList[a]+';')
fileName.write('\r\n')
#############################
fileName.write('MAYA_PLUG_IN_PATH = ')
for a in range(len(pluginPathLsit)):
fileName.write(pluginPathLsit[a]+';')
fileName.write('\r\n')
#############################
fileName.close()
#############################
cmds.confirmDialog(t=u'提示!', m=u'插件已经安装完成,重启maya后即可使用!', b='OK', db='OK', cb='OK', ds='OK')
finally:
fileName.close()
############################################################
setEnvPath()
aaa
最新推荐文章于 2024-04-20 00:25:36 发布