Skip to content

Instantly share code, notes, and snippets.

@EricTRocks
Created September 20, 2016 03:43
Show Gist options
  • Save EricTRocks/88545fe7cbfec9957b6a84660f7b93a8 to your computer and use it in GitHub Desktop.
Save EricTRocks/88545fe7cbfec9957b6a84660f7b93a8 to your computer and use it in GitHub Desktop.
Invert BlendShape weights
from maya import cmds
import pymel.core as pm
sel = pm.ls(selection=True)
print sel[0]
blends = sel[0].getShape().inputs(type='blendShape')
if len(blends) < 1:
print "No blend shapes on this node!"
else:
vertexCount = pm.polyEvaluate(sel[0], vertex=True)
weights = blends[0].inputTarget[0].baseWeights.get()
newWeights = [1.0 - x for x in weights]
for i, wt in enumerate(weights):
blends[0].inputTarget[0].baseWeights[i].set(newWeights[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment