Feedback

What's your question?

By: Asked

Can I get the exact selection order in component level?

I have a polygon (say "pCube1"), if I select vertices in the following order:

pCube1.vtx[5]
pCube1.vtx[4]
pCube1.vtx[2]

then execute:

string $sel[] = `ls -sl -flatten`;  
print $sel;

I get the following :

pCube1.vtx[2]
pCube1.vtx[4]
pCube1.vtx[5]

Is there a way to maintain selection order?

Add comment viewed 97 times Latest activity 10 months ago

or Cancel

3 answers

  • 1

oodini

Look at the polySelect command. Never used though.

NN comments
julian
-

Looks like a very handy command. I couldn’t figure out how it could be used to get an existing selection in the order it was picked though.

or Cancel
  • 0

julian [ Admin ]

Maybe you could create a global variable to hold the ordered selection list and then update it every time the selection changes.

global string $gOrderedSelection[];
scriptJob -e "SelectionChanged" "updateOrderedSelection()";

updateOrderedSelection needs to do a lot of work, because you can't know just what changed, you have to look at the whole selection list each time.

global proc updateOrderedSelection(){

    string $sel[] = `ls -sl -flatten`;
    // if $sel is empty clear $gOrderedSelection and return
    for ($s in $sel) {
        // if $s is in  $gOrderedSelection then ignore it
        // if $s is not in $gOrderedSelection then append it
    }
    for ($o in  $gOrderedSelection) {
        // if $o is in  $sel then ignore it
        // if $o is not in $sel then remove it from the $gOrderedSelection
    }
}

Maybe this is overkill and slow - but it could work.

Another option would be to write a custom selection context, probably possible with python even. In that way you would have access to the components that were selected or unselected in each event.

NN comments
potinana
-

Thank you.. This works great.

or Cancel
  • 0

manny [ Editor ]

Yes you can. It's called the script editor window. Just scroll up to see your selection window. Not being flippant here. It's the best way to see what order things happened.

Now if you're goal is to script something, then that's a whole different animal.

or Cancel