Force updating of skin cluster num elements

26 views
Skip to first unread message

Brennan Chapman

unread,
Feb 4, 2015, 8:43:56 PM2/4/15
to python_in...@googlegroups.com
I'm working on some rigging tools to copy weights between identical nurbs surfaces.
Having trouble with getting a consistent list of weights from a skin cluster.

I create a nurbs sphere, 3 joints, and used a smooth bind.
Right after doing this, I get the skin cluster using pymel and ask for the number of elements in the weight list.
skin.wl.numElements()
>> 54

Then, I open up the node editor, graph the connections on my mesh, find the skin cluster, and press "3" to expand the skin cluster node.
Returning to python, if I ask for the number of elements again, I get more...
skin.wl.numElements()
>> 74

I haven't done anything else between these two steps.

I can also achieve this same growth from 54 to 74 by opening up the paint weights tool, and painting a couple points.

From what I've tried so far it seems that once I reach 74, no amount of painting/changing weights increases the count of the elements past it.

I'm trying to figure out what's going on that triggers this growth, and if I can use a command right after the smooth bind to force it to go from 54 to 74.

The context for this is that we have riggers that build rigs, save a copy of the built rig and paint weights on it.
Then they can import these weights into the rig as it's building the next time.
However, if the weights list is changing lengths in the weights file, I can't correctly match it up to the fresh smooth bind when the rig is being built.

Working in Maya 2015 Ext 1 - SP5

Thanks,
Brennan

Brennan Chapman

unread,
Feb 5, 2015, 11:28:23 AM2/5/15
to python_in...@googlegroups.com
Figured it out.
I was also trying to use the api to get the number of elements.
weightListPlug = skin.wl.__apiobject__()
weightListPlug.numElements()
>> 56
Same issue, however if in the api, if I switch to getExistingArrayAttributeIndices, I get the exact weight list ids I need.
infIDs = api.MIntArray()
weightListPlug.getExistingArrayAttributeIndices(infIDs)
>> [1,2,...]

Found this from:

The fastest and most python friendly way to query a skinCluster's weights (that I know about) is to use MPlug. There is an attribute on the skinCluster called weightList, whose index is the vertex id, which has a child attribute called weights, whose index is the influence id, which stores the weight value. The great thing for skin weights is maya only "activates" the influence ids in this weights attribute that are non-zero for the vertex.
 
MPlug.getExistingArrayAttributeIndices returns the indices of these non-zero weights. Technically a zero value could exist, but unless you set it manually that shouldn't happen for skin weights (and could bloat your file size if you went around setting a bunch of zeroes).

So the numElements isn't including some of the weights that haven't been "activated"

-Brennan
Reply all
Reply to author
Forward
0 new messages