Oh woops; I'm sorry you were asking about individual vertices—this is just for the weight of the whole shape
On Tue, Jan 26, 2010 at 12:27 PM, Adam Mechtley <[email protected]>wrote: > This was an example from an Autodesk training course I attended, so I > presume it's the "best" way to do it > > blendShapeNode = OM.MObject() > selList = OM.MSelectionList() > > try: > # Get the selected blendShape node > OM.MGlobal.getActiveSelectionList(selList) > > if(selList.length() !=0 ): > selList.getDependNode(0,blendShapeNode) > > fnDep = OM.MFnDependencyNode(blendShapeNode) > > # Verify that the node is a Blend Shape > if (blendShapeNode.apiType() == OM.MFn.kBlendShape ): > attrName = "weight"; > weightArrayPlug = fnDep.findPlug(attrName) > > # Find out if this plug is a multi plug > if(weightArrayPlug.isArray()): > # Get the name of the plug and print it > plugName = weightArrayPlug.name() > print("Plug %s is an array plug." % plugName) > > # Find how many elements are in this multi plug > numberOfElem = weightArrayPlug.numElements() > print("This plug has %i elements." % numberOfElem) > > # Traverse all the element plugs > for j in range( 0, numberOfElem ): > > elementPlug = weightArrayPlug.elementByPhysicalIndex(j) > > # Print out the element plug's physical index and > logical index > print "Physical index: %i; Logical index: %i" % (j, > elementPlug.logicalIndex()) > > # Print out the value in every element plug > # NOTE: There is no script support for MPlug.getValue() > valueElem = elementPlug.asDouble() > print("The value in this element plug is %f" % > valueElem) > except: > print("Failed to get selection list") > raise > > > On Tue, Jan 26, 2010 at 12:13 PM, Brandon Harris <[email protected]>wrote: > >> Forgot to post. I'm meaning in API. I know how to do this in Mel. >> >> >> On Jan 26, 12:13 pm, Brandon Harris <[email protected]> wrote: >> > I'm still looking, but thought I would ask here, is there a way to >> > grab blendshape weights for individual vertices. >> >> -- >> http://groups.google.com/group/python_inside_maya >> > > -- http://groups.google.com/group/python_inside_maya
