Here is what I done recently to achieve the soft selection results.
 
import maya.OpenMaya as OpenMaya
def softSelection():
    #Grab the soft selection
    selection = OpenMaya.MSelectionList()
    softSelection = OpenMaya.MRichSelection()
    OpenMaya.MGlobal.getRichSelection(softSelection)
    softSelection.getSelection(selection)
   
    dagPath = OpenMaya.MDagPath()
    component = OpenMaya.MObject()
   
    # Filter Defeats the purpose of the else statement
    iter = OpenMaya.MItSelectionList( selection,OpenMaya.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 = OpenMaya.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
elements,weights = softSelection()
 
 
 
-Brian Escribano
www.meljunky.com
 
-------- Original Message --------
Subject: Re: [Maya-Python] query soft selection
From: Michiel Duvekot <[email protected]>
Date: Mon, July 04, 2011 3:32 pm
To: [email protected]

Here's an idea: http://www.thnkr.com/wiki/index.php?title=Convert_soft_selection_to_a_cluster


On Mon, Jul 4, 2011 at 6:21 PM, Sebastian Schoellhammer <[email protected]> wrote:
Hello!

Is there any way of querying the components affected in the current softselection?

If I can't what would be the best way to calculate them myself? Checking against all positions in the mesh must be superslow of course.
I'm sure maya is using some acceleration structures internally to speed this up?

I guess I could grow the selection a couple of times and just use those components but thats wacky and wouldn't work for a volume..
Any ideas?

Thanks!!

seb
 
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe



--
--
Michiel
 
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe

--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to