导入物体数值代码(驱动镜像以及拷贝时候很好用的,配合导出代码使用),回头我会更新个UI
#-------------------------------import obj attr number----------------------#
import maya.cmds as mc
import os
File_NAme='L_mth_open_dnInn.txt'
File_save_path=r'D:\ten_lives\rose_default_new\head\sdk'
#赋予数值时候 原来的 'lf' 替换给 'rt' 控制器
ORGName='facial_lf_'
NEwNAme='facial_rt_'
#由于替换的已经赋值,后面遇见的就要忽略 否则会覆盖成0 一般来说就等于被替换的物体
needCancelNum='facial_rt_'
#赋予负值或者正值
tx=-1
ty=1
tz=1
rx=1
ry=1
rz=1
sx=1
sy=1
sz=1
##考虑中间非左右对称的单独处理 (带有 pos_M_ 字符的单独为 *-1 或者 *+1 )
myCenterNameWith='facial_cn_'
CenterCtlMirror_tx=-1
CenterCtlMirror_ty=1
CenterCtlMirror_tz=1
CenterCtlMirror_rx=1
CenterCtlMirror_ry=1
CenterCtlMirror_rz=1
CenterCtlMirror_sx=1
CenterCtlMirror_sy=1
CenterCtlMirror_sz=1
#_____________________________________________________________________
mySaveFinalFile01=File_save_path+'\\'+File_NAme
mySaveFinalFile=mySaveFinalFile01.replace('\\','/')
if os.path.exists(mySaveFinalFile)==True:
f = open(mySaveFinalFile).read()
#try:
# allLetter=f.read()
#finally:
# allLetter=f.close()
print f
myallObj=f.split('@')
if myallObj!=None:
for a in range(len(myallObj)):
#物体存在
if mc.objExists(myallObj[a].split('&')[0]):
#是否负
myDefaultAttr=myallObj[a].split(':')[0].split('&')[1]
myNeedNums=float(myallObj[a].split(':')[1])
if myDefaultAttr=='translateX':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_tx
else:
myNeedNums=myNeedNums*tx
elif myDefaultAttr=='translateY':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_ty
else:
myNeedNums=myNeedNums*ty
elif myDefaultAttr=='translateZ':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_tz
else:
myNeedNums=myNeedNums*tz
elif myDefaultAttr=='rotateX':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_rx
else:
myNeedNums=myNeedNums*rx
elif myDefaultAttr=='rotateY':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_ry
else:
myNeedNums=myNeedNums*ry
elif myDefaultAttr=='rotateZ':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_rz
else:
myNeedNums=myNeedNums*rz
elif myDefaultAttr=='scaleX':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_sx
else:
myNeedNums=myNeedNums*sx
elif myDefaultAttr=='scaleY':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_sy
else:
myNeedNums=myNeedNums*sy
elif myDefaultAttr=='scaleZ':
if myCenterNameWith in myallObj[a].split('&')[0]:
myNeedNums=myNeedNums*CenterCtlMirror_sz
else:
myNeedNums=myNeedNums*sz
#存在需替换名字就替换
if ORGName in myallObj[a].split('&')[0]:
if mc.objExists( myallObj[a].split(':')[0].replace(ORGName,NEwNAme).replace('&','.') ):
mc.setAttr( myallObj[a].split(':')[0].replace(ORGName,NEwNAme).replace('&','.'), myNeedNums )
else:
pass
elif ORGName not in myallObj[a].split('&')[0]:
if needCancelNum in myallObj[a].split('&')[0]:
pass
else:
mc.setAttr( myallObj[a].split(':')[0].replace('&','.'),myNeedNums )
欢迎交流
VX:27971533