Quantcast
Channel: mel wiki
Viewing all articles
Browse latest Browse all 610

How can I get a list of component-level selections, in the order picked?

$
0
0
When I originally created this post in Jan of 09', Maya had no built-in way for tracking component level selection order: You'd pick a bunch of verts (for example), and the ls command would return them back in... probably some other order.

In later versions of Maya, -ls added a -orderedSelection flag that you could use instead of the -selection flag. But this only worked if you first executed this command:
selectPref  -trackSelectionOrder 1;
Doing that, ls would now return component-level selections in the correct order.

Sometime in Maya 2015, maybe during a service-pack update, this functionality seemed to break though. Long story short: If you execute the above slectPref command twice in a row, ls -orderedSelection would return an empty list. Turning it off, then back on would get ls to return items again, but now in the wrong order.
SO, if you have code that depends on this, you now need to add in something like this:
if (`selectPref -q -trackSelectionOrder` == 0){
    selectPref  -trackSelectionOrder 1;
}
Basically, if it's off, turn it on, but if it's on, just leave it alone. As of this posting (Maya 2016) I've bugged this with Autodesk.

If you want to prove this yourself, here's an example:
// make a cube, select some verts in a specific order:
polyCube -w 1 -h 1 -d 1 -sx 3 -sy 3 -sz 3 -ax 0 1 0 -cuv 4 -ch 1;
select -r pCube1.vtx[49] ;
select -tgl pCube1.vtx[1] ;
select -tgl pCube1.vtx[10] ;

// What state is our selection order tracking in?  Mine is always on by default:
int $trackState = `selectPref -q -trackSelectionOrder`;
// 1

// Print the selection:
ls -orderedSelection;
// Result: pCube1.vtx[49] pCube1.vtx[1] pCube1.vtx[10] //  THE CORRECT ORDER!

// Turn selection tracking on.  I'd exepct this to not change anything but...
selectPref  -trackSelectionOrder 1;
ls -orderedSelection;
// PRINTS NOTHING.  What?!?!

// Turn selection tracking OFF
selectPref -trackSelectionOrder 0;
ls -orderedSelection;
// Result: pCube1.vtx[1] pCube1.vtx[10] pCube1.vtx[49] //  THE WRONG ORDER (as expected...)

// Turn selection tracking back ON
selectPref -trackSelectionOrder 1;
ls -orderedSelection;
// Result: pCube1.vtx[1] pCube1.vtx[10] pCube1.vtx[49] //  THE WRONG ORDER (not expected...)

Viewing all articles
Browse latest Browse all 610

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>