PDA

View Full Version : [Python]remove blendShape's targets


holycause
12-10-2010, 09:06 AM
hi guys.

I've a question regarding the blendShape.

I try to remove some of my blendshape's targets but it doesn't seems to work.
I tried it like this:


cnt = cmds.blendShape('blendShape1',query=True,wc=True) tmpList = []
for i in range(cnt):
ttList =[]
ttList.append(cmds.blendShape('blendShape1',query=True,t=True)[i])
ttList.append(cmds.blendShape('blendShape1',query=True,w=True)[i])
tmpList.append(ttList)
print tmpList
for b in tmpList:
cmds.blendShape('blendShape1',edit=True,remove=True,g='{0}'.format(b[0]))

any ideas?

Kecal
12-28-2010, 11:37 AM
hi,
this should work, you only need to have original target shapes. If you dont, create temporary shapes with same name and connect them to blendshape node.

# to get targets
blendTargets = cmds.listAttr (blendShapeNode + '.w', m = True)
# to get object influenced by blendShape
history = cmds.listHistory (blendShapeNode, f=True, lf = True)
shape = cmds.ls (history, type = ('mesh','nurbsSurface','nurbsCurve'))
object = cmds.listRelatives (shape, fullPath = True, parent = True, type = 'transform')[0]
for i in range(len(blendTargets)):
cmds.blendShape (blendShapeNode, edit=True, remove = True, t=(object, i, blendTargets[i], 1.0) )

CGTalk Moderation
12-28-2010, 11:37 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.