#===============================================================================
# ParentShape
# author: yangjie
# mobilePhone:15850792203
# QQ:691633493
# E-mail:691633493@
#version:2.0
#===============================================================================
from maya.cmds import*
def YJ_Parent_Shape(ShapeObj,TarObj,Sel,add):
if Sel==1:
YJ_Slected_List=ls(sl=1)
elif Sel==0:
YJ_Slected_List=[ShapeObj,TarObj]
if len(YJ_Slected_List)==2:
YJ_First_Obj=YJ_Slected_List[0]
YJ_Second_Obj=YJ_Slected_List[-1]
YJ_First_Obj_shapeName= listRelatives(YJ_First_Obj,s=1)
YJ_First_Obj_shapeName_Str=YJ_First_Obj_shapeName[-1]
YJ_Second_Obj_shapeName= listRelatives(YJ_Second_Obj,s=1)
YJ_Second_Obj_NshapeName=YJ_First_Obj_shapeName_Str.replace(YJ_First_Obj,YJ_Second_Obj)
parent(YJ_First_Obj_shapeName,YJ_Second_Obj,shape=True,add=1)
if add==0:
try:
parent(YJ_Second_Obj_shapeName,shape=True,rm=True)
except:
print 'No Shape Before'
delete(YJ_First_Obj)
rename (YJ_First_Obj_shapeName,YJ_Second_Obj_NshapeName)
else:
print 'Please Just Select Two Objs'