QUOTE(tscott1213 @ 02/19/06, 07:06 AM) [snapback]228579[/snapback]
Ultimately, I am iterating through the vertices in a skinCluster to get all the weights.
Ultimately thats something you never want to do! See getAttr is a pretty heavy operation. Since the entire command actualy works with a database (mayas a database), just like no sane sql programmer would never do a loop to ask for each and every walue in text database you shouldnt do that in maya either, since each querry carries a quite hefty startingcost. You wantto do this ALL in as few querries as you and you can in 2! So get the entire dataset and then iterate the dataset.
Ok so ill need to teach you how maya realy works here, the thing is you should underatsnd taht the far MOST usefull section of yoru manual is the NODE REFERENCE, most pople dont seem to care but you should.
CODE
{
$clusters=ls ("-type", "skinCluster", listHistory
);
for ($cluster in $clusters){
$numVerts=getAttr -s ($cluster+".weightList")
;
$bones=listConnections ($cluster+".matrix")
;
$numBones= size($bones);
$weights=getAttr ($cluster+".weightList[0:" +($numVerts-1)+"].w[0:"+($numBones-1)+"]");
// note: be sure to subtract -1 or youll make
// the arrays bigger all the time till maya crashes!
print ($cluster+":\n");
print $weights;
}
}
this prints out the rew data its ordered in vertex cluster order, for the selection. (you maya select multiple items if you wish its quite prettyprint)
so the first value is vertex 0 bone0 weight next is vertex 0 bone1 ... vertex 0 bone n then vertex 1 bone 0.... vertex n n.
Note doing only 2 gettar querries is about $numBones/2 times faster taht iterating each one separately now manipulating teh data afterwards in afor loop IS not a speed issue.