View Full Version : How do I do I break up a list of vertices?

11 November 2011, 03:47 AM
Maya often likes to group vertices using shorthand like vtx[7:12] instead of vtx[7], vtx[8]...vtx[12].

This is super annoying when you need to iterate through a group of vertices to do some task in a for loop because some commands only take one argument not multiple ones.

An example would be if I had a group of vertices selected.

for i in vertexGroup:

worldPos = cmds.pointPosition(i) <- only takes one point, not a group of points that Maya organizes.

How do I split up the vertices?

Thank you,

11 November 2011, 03:51 AM
The flatten flag will do that. For example:

ls -sl;
// Result: pSphere1.vtx[294:296] //

ls -sl -flatten; // Result: pSphere1.vtx[294] pSphere1.vtx[295] pSphere1.vtx[296] //

11 November 2011, 04:35 AM
lookup the filterExpand command.
you pass it a variable containing your packed selection list and it returns it unpacked, though you have to filter it by type of components.
But it doesn't requires you to have stuff selected.

11 November 2011, 05:25 AM
Thank you so much! I really want to hug the both of you!

CGTalk Moderation
11 November 2011, 05:25 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.