PDA

View Full Version : How to get the edges list by selecting order via MEL?


Tony_cgtalk
06-14-2005, 04:51 PM
Hi!
I have a question: I tried to get edges list to a array by their selected order, but I used `ls -sl` or `filterExpand` command, I found edges was placed by their index number.
So how can I do?
Thanks!

mhovland
06-14-2005, 05:38 PM
There is no easy way. There have been a few threads on CG-Talk on ways to do this through MEL, like reading the undo que and then reversing it to get the selection order. Try a search and you should find them.

chalbers
06-17-2005, 04:47 AM
It's sad that DAG object selection DOES keep the order in the list. But component selection doesn't

Maybe I should suggest it for 7.0

Frank

chalbers
06-17-2005, 06:16 AM
I thought it was a fun problem to solve.

Here is the resulting code. Put it in a selectOrder.mel file inside of your mel scripts directory so Maya can find it.

When you run "selectOrder" it will warn you that it's starting to follow your edge seletions and it will return an empty string array. Start clicking away on edges !

Once done, run "selectOrder" again, and it will return you the ordered selection of all your edges since you started it the first time. Keeping on toggling that proggy will start and end new selection sessions.

Enjoy !

global string $selectOrder_edges[];
global string $selectOrder_updateSet;
global int $selectOrder_jobNum;

global proc string[] selectOrder ()
{
// Get globals
global string $selectOrder_edges[];
global string $selectOrder_updateSet;
global int $selectOrder_jobNum;

if ( !`scriptJob -exists $selectOrder_jobNum` || $selectOrder_jobNum == 0 ) {
warning "Start selection Order!\n";
$selectOrder_edges = {};
string $selEdges[] = `ls -sl "*.e
"`;
$selectOrder_updateSet = `sets -n selectOrderSet $selEdges`;
$selectOrder_jobNum = `scriptJob -event SelectionChanged "selectOrder.update"`;
} else {
warning "End of selection Order!\n";
delete $selectOrder_updateSet;
scriptJob -kill $selectOrder_jobNum -force;
}
return $selectOrder_edges;
}

global proc selectOrder.update ()
{
// Get Globals
global string $selectOrder_edges[];
global string $selectOrder_updateSet;

// Get change
string $selEdges[] = `ls -sl "*.e
"`;
string $tempSet = `sets -n selectOrderSetTemp $selEdges`;
string $diff[] = `sets -sub $tempSet $selectOrder_updateSet`;
$diff = `ls -fl $diff`;
$selectOrder_edges = stringArrayCatenate($selectOrder_edges,$diff);
delete $tempSet;
delete $selectOrder_updateSet;
$selectOrder_updateSet = `sets -n selectOrderSet $selEdges`;
}

CGTalk Moderation
06-17-2005, 06:16 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.