PDA

View Full Version : vert selection order


ooklah
01-29-2008, 12:29 PM
I made a small script that copies the weight of one vertex to a second vertex. It worked on the test skin that I had been useing when making the script. But when I took it to actually use it on a model, I discovered that the ls -sl did not actually give me back the verts in the order that I had selected them. It gave them back in numeric order which didn't work.

I found this thread http://forums.cgsociety.org/showthread.php?f=89&t=88947 from five years ago, which has a procedure that goes back through the undo list to get the correct order. With that I was able to get my script working again.

I wanted to know though, is there was any better way to get the correct vert order, five years later?

mhovland
01-29-2008, 02:36 PM
I believe in Maya 2008, there is a command to returnComponentsInOrder, or some such, you'll have to check the docs. I saw it when I was running through them, and thought "Now that will be usefull" and continued on my way.

I don't remember if it is an actual command, or a script that is included. Either way, wouldn't it be ironic if the "new" method, was just an Autodesk/Alias implementation of the aforementioned script?

Robert Bateman
01-29-2008, 03:25 PM
http://forums.cgsociety.org/showthread.php?f=89&t=485206

tbaypaul
01-29-2008, 08:05 PM
.......there seems to be a small problem in their attachTool context example........the preformAttachCrv() takes two input variables....so I had to change the -finalCommandScript to include the second one as "" for the $goToTool.....that eliminated the (// Error: Wrong number of arguments on call to performAttachCrv. you big dummy, geez louise!) error I was getting in 2008 and made the script work correctly.

-fcs "select -r $Selection1; performAttachCrv 0 ;"
to:
-fcs "select -r $Selection1; performAttachCrv 0 \"\";"

ooklah
01-30-2008, 01:57 AM
Thanks, I didn't see anything in the documents. I'll look again though.

I'll have to look into that scriptCtx thing more, I don't know what it is currently or how I would use it.

My current script is working well enough for what I need to do. I had just wondered if there was a fix that I couldn't find or something.

tbaypaul
01-31-2008, 04:32 PM
unfortunately, sciptCtx, is no more the answer then any of the other methods....such as......popping the undo like sz_ReturnComponentSelectionInOrder script.....the scriptCtx will return components in "nice" order just like every other selection list in maya. I posted my context to ask Autodesk and their reply was as follows:


......using the $Selection1 predefined variable of the
scriptCtx isn't going to avoid this limitation because Maya is returning from
the active selection.

The only possible way of storing vertex selection by order is by selecting one
by one and storing the selection order in a string array or storing the index
only in an int array.

Make your scriptCtx select one vertex at a time. Make it start a scriptJob on the
-toolStart script to monitor selection change and kill the scriptJob when the
scriptCtx is exited. The scriptJob callback would then store each selection on a
global string array variable or store the index of the selection in a global int
array. Remember to also clear the global variable from your -toolStart script as
well.


My scriptCtx for the post:

if(!`contextInfo -exists selectionOrder`){
scriptCtx
-title "Selection Order"
-totalSelectionSets 1
-toolCursorType "edit"
-fcs "select -r $Selection1; print \"Vertices are not in order of selection:\\n\"; print $Selection1;"
-cumulativeLists false
-expandSelectionList true
-setNoSelectionPrompt "Select, in any order, vertices on a single object."
-setSelectionPrompt "Select second point."
-setDoneSelectionPrompt "Press Enter to complete the tool."
-setNoSelectionHeadsUp "Please select some vertices."
-setSelectionHeadsUp "Press Enter to complete tool."
-setAutoToggleSelection true
-setSelectionCount 0
-setAutoComplete false
-polymeshVertex true
selectionOrder;
}
setToolTo selectionOrder;

CGTalk Moderation
01-31-2008, 04:32 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.