Blendshape get base weights

68 views
Skip to first unread message

johan Borgström

unread,
Mar 13, 2015, 6:48:48 AM3/13/15
to python_in...@googlegroups.com
Hi,

I want to be able to get and set the base weights of a blendshape. In the example below I am using pymel to get the base weights. If I first edit the weights in the component editor and then run the script it returns a tuple of weights, but if I have not manually edited the weights I get an empty tuple back. The same is true if I view the node in the node editor, first the baseWeight slot is empty but if I edit the weights, the weights are displayed.

How can I get and set the base weights programatically using pymel? is that possible?

crv_1 = pm.curve(d=1, p=[(0,0,0), (10,10,0)], n='crv_1')
crv_2 = pm.curve(d=1, p=[(0,0,0), (10,0,0)], n='crv_2')

bs = pm.blendShape(crv_1, crv_2)[0]

bs_weights = bs.inputTarget[0].baseWeights.get()
print(bs_weights)


BR,
Johan

johan Borgström

unread,
Mar 18, 2015, 11:49:59 AM3/18/15
to python_in...@googlegroups.com
For completion, here is what I found out. If I loop through the cvs and set the weights, it works as expected.

crv_1 = pm.curve(d=1, p=[(0,5,0), (10,10,0)], n='crv_1')
crv_2 = pm.curve(d=1, p=[(0,0,0), (10,0,0)], n='crv_2')

bs = pm.blendShape(crv_1, crv_2)[0]

print(bs.inputTarget[0].baseWeights.get())
# result: ()

num_cvs = crv_2.getShape().numCVs()

# set the weights
for index in range(num_cvs):
    bs.inputTarget[0].baseWeights[index].set(1)


print(bs.inputTarget[0].baseWeights.get())
# result: (1.0, 1.0)


BR,
Johan

Marcus Ottosson

unread,
Mar 18, 2015, 12:14:27 PM3/18/15
to python_in...@googlegroups.com
Thanks for sharing, Johan.
Reply all
Reply to author
Forward
0 new messages