Adding vertices to a selection list?

24 views
Skip to first unread message

buscagliaj...@gmail.com

unread,
May 13, 2015, 3:23:21 PM5/13/15
to python_in...@googlegroups.com
Hi!
I'm having trouble doing something I thought would be very simple to do, which is adding a vertex to a selection list as the question title states. I have a function that takes in a selection list, iterates through all the vertices and groups them into 2 separate sections.

The first thing I tried was to copy the selection list to 2 empty lists, get the current vertex index in the MItMeshVertex and remove said index from the corresponding list. Doing this crashes maya so it seems those are 2 different kind of indices, I'm still very new to the API so I mix up things a lot.

What I am doing right now is way too ugly to be the right way. I build a string with all the vertex IDs that I get from the iterator, add it to a MEL command to select those vertices on the specified object and finally use MGlobal::getActiveSelectionList to store that selection into a new list.
Here's a pastebin with the snippet http://pastebin.com/HeraQg6q

There has to be a better way to do this, I thought about storing each vertex in the iterator as an MObject and adding them to the lists but I'm not sure if I can do that. Any help would be appreciated.
Thanks in advance.

buscagliaj...@gmail.com

unread,
May 14, 2015, 8:16:56 AM5/14/15
to python_in...@googlegroups.com, buscagliaj...@gmail.com
In the end I was able to find out the way to do it by myself, kinda feel bad for asking a question for no reason at all.
If anyone is wondering how, what I did was to use MFnSingleIndexedComponent to add the id array to an MObject, then I could use the .add functionality of selection lists. Just like I thought it was a very simple thing to do.
Reply all
Reply to author
Forward
0 new messages