Skip to content

Instantly share code, notes, and snippets.

@Roumenov
Last active September 28, 2019 22:57
Show Gist options
  • Save Roumenov/8b6602d58bfea23a440c021335ce5fdb to your computer and use it in GitHub Desktop.
Save Roumenov/8b6602d58bfea23a440c021335ce5fdb to your computer and use it in GitHub Desktop.
bunch of messy procs for moving skinweights to bind joints and then contraining them to the prior
#bunch of messy procs for moving skinweights to bind joints and then contraining them to the prior
import pymel.core as pm
target_mesh = pm.ls(sl=1)[0]# unpack selection
target_skinCluster = target_mesh.listHistory(type='skinCluster')[0] # pm.mel.findRelatedSkinCluster(target_mesh) should also work
source_influence, target_influence = pm.ls(sl=1)[0:2]# unpack selection
target_skinCluster.addInfluence(target_influence, weight = 0.0)
constraint = pm.parentConstraint (source_influence, target_influence, mo = 1, weight = 1)
constraint.setAttr('interpType', 2)
pm.scaleConstraint(source_influence, target_influence, mo = True)
uf.meta_make_child(source_influence, target_influence) # TODO: replace this with the red9 version
pm.select(target_mesh+".vtx[*]")
pm.skinPercent(target_skinCluster, tmw=[source_influence, target_influence]) # the data from the first will be written to the second
pm.select(cl=1)
target_skinCluster.removeInfluence(source_influence)
@Roumenov
Copy link
Author

this is limited to 1:1 mapping between influences
should query existing influences, then add the new value to any existing value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment