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: http://www.charactersetup.com/tutorial_skinWeights.html 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 On Wednesday, February 4, 2015 at 7:43:56 PM UTC-6, Brennan Chapman wrote: > > 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 > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3063ec24-f40a-4ae8-989d-458576a2b09a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
