Binding skin using skinCluster command
# using skinCluster command to bind smooth skin to the selected mesh with selected joints
def doBindSmoothSkin():
import maya.cmds as mc;
skin=False;
bones=[];
# getting bones and a skin mesh
sel = mc.ls(sl=1,l=1,o=1);
for obj in sel:
if mc.nodeType(obj)=="joint":
bones.append(obj);
elif mc.objExists(obj+".vtx[*]"):
shapes=mc.ls(mc.listRelatives(obj,ad=0),type="mesh");
hist=mc.ls(mc.listHistory(shapes),type="skinCluster");
if not len(hist):
skin=obj;
if skin and len(bones):
# do skinBind
bsArgs = {
'name': 'skinCluster',
'toSelectedBones': True,
'bindMethod': 0,
'skinMethod': 0,
'normalizeWeights': 0
};
mc.skinCluster(bones, skin, **bsArgs);
mc.select(bones,skin);
def doBindSmoothSkin():
import maya.cmds as mc;
skin=False;
bones=[];
# getting bones and a skin mesh
sel = mc.ls(sl=1,l=1,o=1);
for obj in sel:
if mc.nodeType(obj)=="joint":
bones.append(obj);
elif mc.objExists(obj+".vtx[*]"):
shapes=mc.ls(mc.listRelatives(obj,ad=0),type="mesh");
hist=mc.ls(mc.listHistory(shapes),type="skinCluster");
if not len(hist):
skin=obj;
if skin and len(bones):
# do skinBind
bsArgs = {
'name': 'skinCluster',
'toSelectedBones': True,
'bindMethod': 0,
'skinMethod': 0,
'normalizeWeights': 0
};
mc.skinCluster(bones, skin, **bsArgs);
mc.select(bones,skin);
Comments
Post a Comment