PDA

View Full Version : Selection order of components


Buexe
09-17-2003, 08:21 PM
Hi everybody, I would like to copy weights from one vertex to another by selecting them and then start the proc. But I need to get the first or the last to be the "source" vertex from which to copy the skin percentages to the other vertices. If I use "ls -sl -fl" I get the vertices in the their numeric order not in the order I selected them. Is there a way to query the last or the first selected item?
TIA
buexe

mhovland
09-17-2003, 08:56 PM
I wish I could give you a more definative answer, but I remeber a discussion a while back that covered this (where I saw it I don't know. It might have been on Highend3d, or the Maya-dev listserv).

Unfortunately it wasn't easy. It involved traversing the undo que, and figuring out the order of selection based on the reverse of the contents of the undo que.

Messy at best.

You might try selecting one vert to copy from and running the copy procedure, then selecting the target vert/verts and running your paste.

galactor
09-17-2003, 09:06 PM
You can make the script in such a way that you select the first vertex manualy, it then query's the weight value. Stores it in an array, select all the other vertices and automaticly apply the value to the other vertices.

or if you wan't to decide yourself wich vertices must be selected you could make use of an interface that allows you to store the first selected vertex (with a button )and later on applies it to the next selectin you made (triggered by another button.)

:: Galactor ::

Buexe
09-18-2003, 11:35 AM
Thanks guys, the way galactor proposed is how I currently do it, I just thought there must be a better way, since there are a couple of Maya Tools where it is also crucial in which order you select the items, but maybe the undo queue is something I`ll try.
Thankx a lot
buexe

alesmav
09-18-2003, 12:05 PM
Sure there is a way to select first and last selected object. If you have the array, then for example $selObjects[0] is the first selected object. Then you use the command 'size' to return the number of selected objects in the array. Using this number (-1 of course, cos 0 also counts), you can get to the last selected object.

ALES

galactor
09-18-2003, 12:34 PM
Ales, that works for objects, but not for the components that objects are built from (vertices, edges, faces).

:: Galactor ::

alesmav
09-18-2003, 12:51 PM
I don't understand. I before posting I did a test in Maya:


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


Now select vertices and execute this script. I can clearly see that vertices and their numbers are stored the array. What is the problem?

ALES

Buexe
09-18-2003, 01:00 PM
The elements are stored in the array but not in the order you select them, instead their identity number is used. For example selct vertex number 24 and then select vertex 2. If you print out the array the first one will be 2 and not 24, which is not the order you selected them.
Anybody know how i can access the undo queue?
cheers buexe

alesmav
09-18-2003, 01:21 PM
Yes, now I see...

I wonder why it doesn't respect the order of selection...

ALES

mhovland
09-18-2003, 01:25 PM
Look at the undoInfo command. It looks like you can query the length of the undo que, as well as the undoName (what will be undone).

It looks like the length will return the length that the que is set to, as infinite will override the length value.

wrend
09-19-2003, 07:35 AM
yep.
cant remember who wrote this unfortuneately:

global proc string [] sz_ReturnComponentSelectionInOrder () {

string $selectionAll[] = `ls -sl`;
string $selection[];
string $realSelection[];
string $buffer[];
string $lastCommand = `undoInfo -q -un`;
int $counter = 0;

while (`match "select" $lastCommand` != "")
{
$lastCommand = `undoInfo -q -un`;
if (`match "select" $lastCommand` != "")
{
tokenize $lastCommand " " $buffer;
$selection [$counter] = $buffer[2];
$counter++;
undo;
}
}
select $selectionAll;

for ($i = 0; $i < (`size $selection`); $i++)
$realSelection [$i] = $selection[(`size $selection` - $i)-1];

return $realSelection;
}

Buexe
09-19-2003, 07:43 AM
:applause: :applause: :applause:
That is wicked! Boy this makes my life so much easier, thanks a trillion!!! Alias should make this a standard option for the ls command but in the meantime there are the good folks of cgTalk.
Thanks again
buexe
:beer:

Buexe
09-19-2003, 08:07 AM
Yo, I have attached the mel script that enables (at least it works here for now) you to copy the skinWeights between vertices of a polyMesh, it should also work between different objects and maybe it works even on nurbs, I never use those, but if you encounter any problems let me know.
Thanks again to all those who contributed!!!
buexe

I have no clue how to put in the code in the reply so that the indents are preserved, maybe someone can tell me. Please don`t forget to rename the txt file to .mel

wrend
09-20-2003, 03:45 AM
heya. noticed that you renamed the return selectn proc with your initials. the proc is a little chunk of sz's art, so id be careful renaming it yours - im sure it wasnt intentional, and wasnt done in a plaguristic sense (i can see you acknowledged cgtalk ppl ...and ive fished out the proc author - Horvatth Szabolcs), just something to watch out for, is all. :)

Buexe
09-20-2003, 09:00 AM
Good you noticed that. I don`t intend to claim other`s work as mine. I just rename the procs I put together (with the help of others) with my initials so I see which one`s I got from highend3d which one`s not and so on. If you think that it is appropriate to put in the names I`ll do that right on the spot. It`s "my" first script I hand out, so I hope one can excuse beginner`s mistakes . If there is still some issue about it don`t hesitate to tell me, because I´m willing to learn.
:beer:

Did you try it?

buexe

So here is the new Version with appropriate credits:

wrend
09-21-2003, 06:52 AM
had a little play now... but im not much of a rigger, so im not sure if im using it right, and im getting a few errors. is the idea that you select a single vertex somewhere on a skinned mesh, and then any number of other vertices on the same mesh, and the script will copy the weight value of that first vertex to all the other selected vertices?

glad you didnt take offense to my pointing out the proc naming thing. it may be of no importance whatsoever to the author, but some can get irky about it all, and its just one of them unspoken etiquet things.

keep it up!

cheers, c.

Buexe
09-21-2003, 12:01 PM
Hey it`s all good, I just don`t know about these etiquet things since I would not consider myself a coder, hacker or whatever one may call it. The script is supposed to work like you said, Skin a mesh to a couple of joints, assign weights to the vertices and when you see wertices where you would like to have the same weighting for the same joints run the proc, so that all vertices get the weighting of the first selected. It works great for me here and I still wonder why this is not a standard smooth skin command in Maya.

Anyway, thanks again for your help wrend
cheers
buexe :wavey:

CGTalk Moderation
01-16-2006, 03:00 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.