OK. I felt it was appropriate to post my issue here because it falls
inline with this issue.
j=0
while not compItr.isDone():
self.tmpOldSkinWeights = []
self.skinCluster.setWeights(self.relatedShape,compItr.currentItem
(),self.infIndices,self.newWeightsArray,True,self.throwAwayWeights)
for i in xrange(self.throwAwayWeights.length()):
self.tmpOldSkinWeights.append(self.throwAwayWeights[i])
self.oldSkinWeights.insert(j, self.tmpOldSkinWeights)
j = j+1
compItr.next()
OK. so first off, this works exactly the way that I want it to. It
takes the new weights and applies them to the proper components. Now
because I'm iterating over the components and the old weights that are
returned are overwritten with each pass, I have elected to catch the
values and put them into a list of lists so I can use them for Undos.
So when I undo I want this to happen.
compItr = openMaya.MItGeometry(self.objectPath, self.objectComps)
i = 0
while not compItr.isDone():
self.skinCluster.setWeights(self.relatedShape,compItr.currentItem
(),self.infIndices,self.oldSkinWeights[i],True,self.throwAwayWeights)
print self.oldSkinWeights[i]
i = i+1
compItr.next()
Now this is basically an exact mirror of the first part that works
correctly (as far as I know) but when used during the Undo it throw
this error.
// Error: line 1: in method 'MFnSkinCluster_setWeights', argument 4 of
type 'unsigned int'
# Traceback (most recent call last):
# File "/data/film/apps/reelfx/maya/plug-ins/linux/2009-x64/
TestCommand.py", line 189, in undoIt
# self.skinCluster.setWeights(self.relatedShape,compItr.currentItem
(),self.infIndices,self.oldSkinWeights[i],True,self.throwAwayWeights)
# TypeError: in method 'MFnSkinCluster_setWeights', argument 4 of type
'unsigned int' //
Also, for my self.infIndices I am doing this.
self.infIndices = openMaya.MIntArray()
for i in xrange(self.skinInfluences.length()):
self.infIndices.append(i)
Hopefully my tabbing hasn't gotten too bad with copying it over here,
but hopefully you get an idea for what I'm doing. It's the same error
meljunky was having, but it works fine unless I'm undoing. thanks in
advance!
Brandon L. Harris