PDA

View Full Version : Components and `ls -sl`


tbaypaul
01-28-2007, 08:08 PM
I never noticed it before, but you lose the selection order of components.

so if you select.....
select -r pSphere1.vtx[238] ;
select -tgl pSphere1.vtx[239] ;
select -tgl pSphere1.vtx[220] ;
select -tgl pSphere1.vtx[221] ;
select -tgl pSphere1.vtx[222] ;

you don't get the right order....even with the flatten flag...you get a nice orderly range, that I don't want.....

pSphere1.vtx[220]
pSphere1.vtx[221]
pSphere1.vtx[222]
pSphere1.vtx[238]
pSphere1.vtx[239]
How the can I get the order????

AndersEgleus
01-28-2007, 08:28 PM
I wrote this procedure a while ago (inspired by a procedure by Horvatth Szabolcs) and haven't looked at it in a while, so it could probably be improved, but I've used it a lot and I think it's pretty safe. The idea is to step back in the undo queue and see if anything was selected that matches the selection and then redo all that was undone and return the list of selected objects that was found. Make sure you pass an array of vertices if you only want the vertex order because the function doesn't care what type of object was selected.// this procedure will return the objects in $selection in the correct order they were selected
// it is inspired by a procedure by Horvatth Szabolcs
proc string [] selectionOrder (string $selection [])
{
if (!`undoInfo -q -st`)
error -sl 1 "Undo must be turned on to determine the correct selection order";
else if (`undoInfo -q -l` < 5 && !`undoInfo -q -in`)
warning -sl 1 "Undo queue size may be to small";
string $lastCommand = "";
string $trueSelectionList [] = {};
string $reversedSelection [] = {};
string $tokenizedCommand [] = {};
string $nameWithoutPaths [] = {};
string $tokenizedSelItem [] = {};
int $numUndos = 0;
while (!`undoInfo -q -uqe` && (size ($reversedSelection) < size ($selection)))
{
$lastCommand = `undoInfo -q -un`;
tokenize $lastCommand " " $tokenizedCommand;
if ($tokenizedCommand [0] == "select")
{
int $cmdCnt = size ($tokenizedCommand);
for ($ci = 1; $ci < $cmdCnt; $ci++)
{
tokenize $tokenizedCommand [$ci] "|" $nameWithoutPaths;
for ($sli = 0; $sli < size ($selection); $sli++)
{
tokenize ($selection [$sli], "|", $tokenizedSelItem);
if (($tokenizedSelItem [size ($tokenizedSelItem) - 1] == $nameWithoutPaths [size ($nameWithoutPaths) - 1]) && !stringArrayCount ($selection [$sli], $reversedSelection))
{
$reversedSelection [size ($reversedSelection)] = $selection [$sli];
}
}
}
}
undo;
$numUndos += 1;
}
for ($un = 0; $un < $numUndos; $un++)
if (!`undoInfo -q -rqe`) redo;
if (size ($reversedSelection) < size ($selection))
error -sl 1 ("Could not determine selection order. Try increasing the undo queue size and reselecting");
for ($si = size ($reversedSelection) - 1; $si >= 0; $si--)
$trueSelectionList [size ($trueSelectionList)] = $reversedSelection [$si];
return $trueSelectionList;
}

tbaypaul
01-28-2007, 11:38 PM
Thanks a lot. That is a brillant idea. Poping the stack, basically........ It's that one time where selection order matters.

thematt
01-29-2007, 07:47 AM
this stuff pop up so many time this thread should either be sticky or integrate into the maya doc :)

anyway thanks a lot Anders, this has bother me sometime also.

sparaig
01-30-2007, 07:29 PM
I never noticed it before, but you lose the selection order of components.

so if you select.....
select -r pSphere1.vtx[238] ;
select -tgl pSphere1.vtx[239] ;
select -tgl pSphere1.vtx[220] ;
select -tgl pSphere1.vtx[221] ;
select -tgl pSphere1.vtx[222] ;

you don't get the right order....even with the flatten flag...you get a nice orderly range, that I don't want.....

pSphere1.vtx[220]
pSphere1.vtx[221]
pSphere1.vtx[222]
pSphere1.vtx[238]
pSphere1.vtx[239]
How the can I get the order????


Check out this script. It takes the script editor feedback and creates the selection straight from that:

http://forums.cgsociety.org/showpost.php?p=4165151&postcount=11

CGTalk Moderation
01-30-2007, 07:29 PM
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.