Hi Spire2,
I am stucked in another problem related to a new script I am working on.
I am trying to paint the blendshape weights on the selected vertices using python:
If I do this way, it looses the exact vertex IDs and sets the blendshape weights on the very first 8 vertices, but thats not what I want. I want to set the blenshape weights on my selected vertices.
import maya.cmds as mc
cmds.polySphere()
cmds.polySphere()
mc.blendShape('pSphere2', 'pSphere1')
mc.setAttr("blendShape1.pSphere2", 1)
mc.cluster('pSphere2')
cmds.xform( r=True, t=(-3, 0, 0) )
selectedVerts = [u'pSphere1.vtx[160]', u'pSphere1.vtx[178]', u'pSphere1.vtx[179]', u'pSphere1.vtx[180]', u'pSphere1.vtx[198]', u'pSphere1.vtx[199]', u'pSphere1.vtx[200]', u'pSphere1.vtx[218]', u'pSphere1.vtx[219]'] #
#mc.select(selectedVerts)
for i in range(len(selectedVerts)):
mc.setAttr('blendShape1.inputTarget[0].baseWeights[%s]'%i, 0)
And if I remove the range and len from the for loop and do it this way:
for i in selectedVerts:
mc.setAttr('blendShape1.inputTarget[0].baseWeights[%s]'%i, 0)
it gives me following error:
Error: RuntimeError: file <maya console> line 2: setAttr: Invalid attribute name: blendShape1.inputTarget[0].baseWeights[pSphere1.vtx[160]]
which make sense, because âbaseWeights[]â attribute is supposed to take only the int.
Any ideas how do we solve this?
Thanks,
Rohit