-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcopySkinInfluenceWeights.py
More file actions
32 lines (25 loc) · 953 Bytes
/
Copy pathcopySkinInfluenceWeights.py
File metadata and controls
32 lines (25 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import maya.cmds as cmds
import maya.mel as mel
"""select the orig bound mesh, then the new unbound target mesh and run"""
sel = cmds.ls(sl=True)
orig = sel[0]
target = sel[1]
#get orig obj joints
try:
jnts = cmds.skinCluster(orig, q=True, influence = True)
except:
cmds.warning("couldn't get skin weights from {}".format(orig))
print jnts
#bind the target with the jnts
try:
targetClus = cmds.skinCluster(jnts, target, bindMethod=0, skinMethod=0, normalizeWeights=2, maximumInfluences = 3, obeyMaxInfluences=False, tsb=True)[0]
print targetClus
except:
cmds.warning("couln't bind to {}".format(target))
#get skin clusters
origClus = mel.eval("findRelatedSkinCluster " + orig)
#copy skin weights from orig to target
try:
cmds.copySkinWeights(ss=origClus, ds=targetClus, noMirror=True, sa="closestPoint", ia="closestJoint")
except:
cmds.warning("couldn't copy skin weights from {0} to {1}".format(orig, target))