[QUOTE=Twiggy;27619]Does the list comprehension thing also work for setting weights? I wrote a tool which crops the influence weights down to 4, but the only way I’ve been able to set the weights so far is by using skinPercent on each individual vert. It took over 10 minutes to crop the weights on a full character :P[/QUOTE]
I can’t speak directly to your question, but can share my experience with my weight influence pruning tool. I use a loop w/ skinPercent and getting meshes down to 4 influences on a 18k vert mesh only takes a minute for me. Below is the loop I use, maybe I’m doing something different?
Discovering Offending Verts
for i in range(0, vertCount):
numOfVertInfluences = cmds.skinPercent( str(skinClusterName[0]) , skinName[0] + '.vtx[' + str(i) +']' , q=True , value=True , ignoreBelow=0.001 )
if (len(numOfVertInfluences) > myNumInfluences ) :
cmds.select(skinName[0] + '.vtx[' + str(i) +']' , add=True)
After discovering the bad verts, I iterate on only those verts:
for vert in badVerts:
#unlock all influences on the vert
influenceNames = pm.skinPercent(skinClusterName[0], vert , query=True, transform=None)
for influence in influenceNames:
cmds.setAttr( influence + '.liw' , 0 )
#---loop to get this down to 4 influences
numOfInfluences = len(pm.skinPercent( skinClusterName[0], vert , ignoreBelow=0.001, query=True, value=True ))
for num in range(0,numOfInfluences - myNumInfluences):
vertValues = pm.skinPercent( skinClusterName[0], vert , ignoreBelow=0.00001, query=True, value=True )
influenceNames = pm.skinPercent(skinClusterName[0], vert , query=True, ignoreBelow=0.00001, transform=None)
lowestValue = vertValues[0]
lowestInfluence = influenceNames[0]
for i in range(0,len(vertValues)) :
if lowestValue >= vertValues[i]:
lowestValue = vertValues[i]
lowestInfluence = influenceNames[i]
cmds.skinPercent( skinClusterName[0], vert, transformValue=[(lowestInfluence, 0)])
Maybe this is helpful for you? This is how I do it anyway.