query soft selection

2,177 views
Skip to first unread message

Sebastian Schoellhammer

unread,
Jul 4, 2011, 6:21:44 PM7/4/11
to python_in...@googlegroups.com
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

Michiel Duvekot

unread,
Jul 4, 2011, 6:32:01 PM7/4/11
to python_in...@googlegroups.com

Chad Vernon

unread,
Jul 4, 2011, 7:43:50 PM7/4/11
to Sebastian Schoellhammer, python_in...@googlegroups.com
You can use mglobal.getRichSelection to get the soft selection and the corresponding weights

Sent from my Windows Phone

From: Sebastian Schoellhammer
Sent: Monday, July 04, 2011 3:21 PM
To: python_in...@googlegroups.com
Subject: [Maya-Python] query soft selection

br...@meljunky.com

unread,
Jul 4, 2011, 7:49:00 PM7/4/11
to python_in...@googlegroups.com
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
 
-------- Original Message --------
Subject: Re: [Maya-Python] query soft selection
From: Michiel Duvekot <mduv...@gmail.com>
Date: Mon, July 04, 2011 3:32 pm
To: python_in...@googlegroups.com

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 <sschoellha...@gmail.com> 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

Sebastian Schoellhammer

unread,
Jul 4, 2011, 11:04:46 PM7/4/11
to python_in...@googlegroups.com
Thanks everybody for the replies, so helpful!


Reply all
Reply to author
Forward
0 new messages