Untitled
unknown
plain_text
4 years ago
2.6 kB
4
Indexable
##get blendshapes with inbetweens ##select 'FCL_head_MESH_GRP_BSuser' --- THATS THE GRP ##This script will extract all bshape with inbetweens and name them accordingly ##This currently works but not with multiple shapes ##No idea Why import pymel.core as pm ##select object sel = pm.selected()[0] child = sel.getChildren()[0] ##we take a first transform we find since they are all going into sam bshape node head = pm.ls('FCL_head_MESH_BSuser') blendNode = pm.listHistory(child,type = 'blendShape')[0] ##blendNode = pm.listConnections(sel.getShape(),type = 'blendShape') extractedBlends =[] ##select bshape node def duplBlendShapesWithInB(blendNode,child): blendAttrSize = cmds.getAttr(blendNode+'.weight') ## here we get a list of all the bshapes values -- mainly to use as a max counter shape = child #loop over the attributes now and get their name info for i in range(len(blendAttrSize[0])): attrName = blendNode + ".weight[" + str(i) + "]" print 'ATTR NAME : ' + attrName ##ATTR NAME : FCL_blendShape1.weight[31] name = cmds.aliasAttr(attrName, q=True) print 'NAME : ' + name ##NAME : FCL_GRP_beak_narrow_dn_R ##check if inbetweens il = blendNode.targetItemIndexList(i,shape) ##[5225,5500,6000] print il for val in il: print val ## this is were we find out if its a blend with inbetweens [5250,5500,6000] or no Ibetweens just [6000] if val == 6000: ## put weight of bshape to 1 and dupl pm.setAttr(attrName,1) ##set blend to 1 dupl = pm.duplicate(head) pm.rename(dupl,name) ## put back to 0 pm.setAttr(attrName,0) extractedBlends.append(dupl) else: ib_val = (val-5000)/1000.0 pm.setAttr(attrName,ib_val) ##set blend to 1 dupl = pm.duplicate(head) nName = name + '__' + str(ib_val) pm.rename(dupl,nName) ## put back to 0 pm.setAttr(attrName,0) extractedBlends.append(dupl) return extractedBlends blends = duplBlendShapesWithInB(blendNode,child) pm.group(blends,n = 'extractedBlends_GRP',world = True) ##bs_node = pm.PyNode('FCL_blendShape1') ##il = bs_node.targetItemIndexList(9, 'FCL_head_MESH_BSuserShape') ##print il ##it will return ##Result: [5279, 5598, 6000] ##otherwise result 6000
Editor is loading...