View Full Version : remember the order of selections.
Fronat 12-20-2006, 12:04 AM Hi
....im having the "selection order" problem to.
if im select 2 uv "pCube1.map[6]" and then "pCube1.map[1]".
when i hit the script i want the first selectet uv to move based on the second selected uv.
but if im putting my selection in an array using the "ls" command it will put the lowest number of my selected uvs at the begining of the array.
exemple.
string $selections[] = `ls -sl`;
$selections[0] is now "pCube1.map[1]" and $selections[1] is now "pCube1.map[6]".
and not based on my selection.
now i want the first selected uv to be put in the $selections[0] even if the uv-number is higher then the second uv selected.
i know iknow the "scriptCtx" is the command to use but i have no ide how to use it and im really confused reading the help on the scriptCtx command.
tnx :)
|
|
wdavidlewis
12-20-2006, 01:11 AM
You may be out of luck. I found this thread: http://www.highend3d.com/maya/list_servers/maya_developers/archive/5303.html
Be sure and expand the text at the bottom for the full explanation. It seems pretty grim for being able to do what you want. However, this was current as of version 4, so hopefully this may have changed.
I was able to get scriptCtx to work (but still showing the selection order problem). Maybe you can tweak it to get it to work the way you want. This is what I used:
global proc processSelection(string $first, string $second) {
print (" First: [" + $first + "]\n");
print ("Second: [" + $second + "]\n");
}
scriptCtx
-title "SelectionOrder"
-totalSelectionSets 1
-fcs "processSelection($Selection1[0], $Selection1[1]);"
-cumulativeLists true
-expandSelectionList true
-setNoSelectionPrompt "Select first vertex"
-setSelectionPrompt "Select second vertex"
-setDoneSelectionPrompt "Im done"
-setAutoToggleSelection true
-setSelectionCount 2
-setAutoComplete true
-vertex
mySelectionTool;
use the setToolTo to set your tool to mySelectionTool.
Hopefully the person in the other thread will reply with how he got it to work.
--- David
Fronat
12-20-2006, 11:55 PM
Tanx David.
I still think its just to tricky to just put a selection in a variable.
i cant undersatnd why alias havenīt done anithing on this.
i should be a simple command or just a flag in the ls command.
By the way i fixed my "selection order" problem useing the "get around big problems using almoust the correct way" way.
since i only have 2 component to query the selection order from i used the sipmle "undo"
command.
first i select my 2 UV-s and put them in a variable.
then i used the "undo" to undo the last selected uv so i only have the first selected uv
and put it in its own variable.
now i select the the seletion in the first variable so both my uv are selected and then toggle the selection whit my new single-uv variable and then i have only the second, last selected uv selected so i can put it int its own variable.
now i have both my uvs separated in variables and by selection order.
the problems with this is that it only workt if i select my two uvs in two clicks so the "undo" can do its job. and this is only for a selection of two.
it should be possible to do this on larger selections using some lopping and use the undo,redo commands.
tanx and feel free to use my simple script :)
sparaig
12-26-2006, 05:24 PM
Hi
....im having the "selection order" problem to.
if im select 2 uv "pCube1.map[6]" and then "pCube1.map[1]".
when i hit the script i want the first selectet uv to move based on the second selected uv.
but if im putting my selection in an array using the "ls" command it will put the lowest number of my selected uvs at the begining of the array.
exemple.
string $selections[] = `ls -sl`;
$selections[0] is now "pCube1.map[1]" and $selections[1] is now "pCube1.map[6]".
and not based on my selection.
now i want the first selected uv to be put in the $selections[0] even if the uv-number is higher then the second uv selected.
i know iknow the "scriptCtx" is the command to use but i have no ide how to use it and im really confused reading the help on the scriptCtx command.
tnx :)
One thing that confuses me about this problem is that Maya itself apparently doesn't have it or at least, the built-in tools implement their own workarounds.
For instance, if I select a set of nurbs curves and loft, it lofts in the order selected, not in the order returned by `ls -sl`.
sparaig
12-26-2006, 06:11 PM
One thing that confuses me about this problem is that Maya itself apparently doesn't have it or at least, the built-in tools implement their own workarounds.
For instance, if I select a set of nurbs curves and loft, it lofts in the order selected, not in the order returned by `ls -sl`.
OK. There's a quick and dirty way to solve this. Create a scriptjob that triggers on selection change and add the newest selected object to your own global list of selected objects. While there are probably ways to make it more elegant, the easiest way to implement it would be to require that only one object be shift-selected at a time. No drag selections. That way, if no other way is available, you can compare membership of YOUR list with the resluts of ls -sl and add the left over selection to the end of your list.
Hope this helps (assuming I understand your problem, of course).
sparaig
12-26-2006, 06:56 PM
OK. There's a quick and dirty way to solve this. Create a scriptjob that triggers on selection change and add the newest selected object to your own global list of selected objects. While there are probably ways to make it more elegant, the easiest way to implement it would be to require that only one object be shift-selected at a time. No drag selections. That way, if no other way is available, you can compare membership of YOUR list with the resluts of ls -sl and add the left over selection to the end of your list.
Hope this helps (assuming I understand your problem, of course).
I read what little could on the subject. High-end 3d's archives appear shot or at least I can't figure out how to access them.
Brian Ewert apparently used this strategy in his MEL How-To 57 then said "kill it" due to performance problems. My own intuition is that you should be able to use such a solution as long as you have a global flag that is checked before the "unworkable solution" is used. IOW, the scriptjob checks to see if the flag is set and if not, it doesn't do anything. If it IS active, then you don't care about "performance" because you've got a specific job to do anyway and it starts accumulating the selection. When you're done, deactivate the selection-monitor. You could make that the last action of your tool script.
In Maya 6, there's at least 4 script jobs normally active that trigger on "selection changed" so I doubt if "selection changed" by itself is a performance killer.
Fronat
12-26-2006, 08:29 PM
tanx for youre replys sparaig.
I dont have so much time right now to but im gonna take this to the bottom.
the biggest reason i want to solve this thing is for learning mel.
i already have the tool i wanted from the begining that snap a shell of uvs to an other uv.
but im thing selection orders of components can be very handy when you script new tools.
so im gonna solve it so i can use it in the future.
tanx for youre support :)
sunit
12-26-2006, 08:37 PM
you can also 1) step through the undo's in order to find the correct selection order or 2) create a custom context.
-sunit
Fronat
12-26-2006, 09:04 PM
you can also 1) step through the undo's in order to find the correct selection order or 2) create a custom context.
-sunit
yes...my ide was to use the undo and catch the seletions in a loop or so.
what do you mean "create a custom contex". im not sure i understand.
tnx
sunit
12-27-2006, 02:34 AM
there's a whole category in the mel docs called contexts. out of these, the scriptCtx allows you to define custom callbacks - in the docs, you'll find a description and a few examples.
-sunit
CGTalk Moderation
12-27-2006, 02:34 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.