def get_soft_selection():
"""
should be a softSelection already selected (components). This returns list of cmpts and list of weights
:return: list of components, and list of weights
"""
# Grab the soft selection
selection = om.MSelectionList()
softSelection = om.MRichSelection()
om.MGlobal.getRichSelection(softSelection)
softSelection.getSelection(selection)
dagPath = om.MDagPath()
component = om.MObject()
# Filter Defeats the purpose of the else statement
iter = om.MItSelectionList(selection, om.MFn.kMeshVertComponent)
elements, weights = [], []
while not iter.isDone():
iter.getDagPath(dagPath, component)
dagPath.pop() # Grab the parent of the shape node
node = dagPath.fullPathName()
fnComp = om.MFnSingleIndexedComponent(component)
getWeight = lambda i: fnComp.weight(i).influence() if fnComp.hasWeights() else 1.0
for i in range(fnComp.elementCount()):
elements.append('%s.vtx[%i]' % (node, fnComp.element(i)))
weights.append(getWeight(i))
iter.next()
return elements, weights
评论列表
文章目录