翻转脚绑定脚本:创建locator
ideas:创建locator,打组,重命名,创建自定义通道控制locator的大小
'''create group LocDrv object and aligns it to selected'''
import maya.cmds as mc
sel = mc.ls(sl=True)
'''for 循环'''
for a in sel:
'''创建loc'''
loc = mc.spaceLocator()
'''打组'''
grpLoc = mc.group(loc)
'''创建约束并删除'''
cons = mc.delete(mc.parentConstraint(a,grpLoc))
'''重命名'''
rnmGrpLoc = mc.rename(grpLoc,"grpLocDrv_"+a)
rnmLoc = mc.rename(loc,"locDrv_"+a)
'''添加属性'''
mc.addAttr(rnmLoc,at='float',longName='Size',keyable=True,defaultValue=1)
'''找到loc的shape节点'''
locshape = mc.listRelatives(rnmLoc,typ='shape')
'''新添加的size属性与shape节点的localsize做连接'''
mc.connectAttr(rnmLoc+'.Size',locshape[0]+'.localScaleX',f=1)
mc.connectAttr(rnmLoc+'.Size',locshape[0]+'.localScaleY',f=1)
mc.connectAttr(rnmLoc+'.Size',locshape[0]+'.localScaleZ',f=1)
'''设置默认大小为100'''
mc.setAttr(rnmLoc+'.Size',100)