# -*- coding:utf-8 -*-
# Author:RDS
#在控制器上添加属性链接到模型shape的display type
import maya.cmds as mc
#cmds.ls(nt=True)
lsall = mc.ls(sl=True)
lsobjshape = mc.listRelatives(lsall , type = 'mesh' )
lscvshape = mc.listRelatives(lsall , type = 'curveShape')
lscv = mc.listRelatives(lscvshape[0] , parent = True , type = 'transform')
mc.addAttr(lscv[0] , ln = 'display_type' , at = 'enum' , en = 'Normal:Template:Reference' , k = True)
for i,data in enumerate(lsobjshape):#用for in循环索引值
mc.setAttr(data+'.overrideEnabled' , 1)
mc.connectAttr(lscv[0]+'.display_type' , data+'.drawOverride.overrideDisplayType')