From time to time I hit into some stupid problem, that I know one of you solved already:
I’m trying to query and set blendshape weights per vertex. Basically I just want to invert currently painted weights, but I’m having problem querying current values so I can 1-x them.
I googled a bit, but this just returns whole bunch of 1.0f instead of correct numbers:
bShapeArray=[]
for i in range(0,vtxCount):
bShapeArray.append( getAttr(‘blendShape1.inputTarget[0].inputTargetGroup[0].targetWeights[’+str(i)+’]’))
I also tried different inputTargets and inputTargetGroups, but I found nothing useful there.
I had success with exporting weights to image, inverting it in photoshop and importing again, but that just seems dumb and waste of time.
That is the correct way to retrieve blendshape target weights.
Couple reasons that may not be getting you what you expect:
You are actually painting weights on the base, not on the target. In this case, the weights are stored on blendShape.inputTarget.baseWeights.
You painted the weights on a different target than the one you are querying. It sounds like this probably isn’t the case if you have tried multiple inputTargetGroups
For speed improvements, you can query all the weights at once instead of using a loop by specifying a slice of vertices: