PDA

View Full Version : Is there a way in MEL to get the right order of the selected components?


KicoTheMan
04-13-2007, 03:56 PM
Is there a way in MEL to get the right order of the selected components?

By doing ls -sl or using the filterExpand command,you get the components but not in the order they were selected.

Cheers

Robert Bateman
04-13-2007, 04:01 PM
use scriptCtx to create a selection based tool....

KicoTheMan
04-13-2007, 06:13 PM
This is from the maya help :
scriptCtx
-title "Attach Curve"
-totalSelectionSets 1
-fcs "select -r $Selection1; performAttachCrv 0;"
-cumulativeLists true
-expandSelectionList true
-setNoSelectionPrompt "Select two curves close to the attachment points"
-setSelectionPrompt "Select a second curve close to the attachment point"
-setDoneSelectionPrompt "Never used because setAutoComplete is set"
-setAutoToggleSelection true
-setSelectionCount 2
-setAutoComplete true
-curveParameterPoint true
attachTool;I executed it and nothing happened.Can you please explain,what exactly scriptCtx is and how it is used?

After i execute this what should i do to see some results?

Cheers

ever_desperate
04-13-2007, 08:43 PM
I believe the 'ls' command already does that.

ever_desperate
04-13-2007, 08:45 PM
I believe the 'ls' command already does that. If you do 'ls -selection' it returns names of the selected objects in the order they were selected. If you take the output of ls -selection in a string array, the first element that is array[0] would contain the object selected first and the last element of the array is the object selected last.

KicoTheMan
04-13-2007, 09:02 PM
ls command does not do that.

Components are still reordered.

isoparmB
04-14-2007, 01:49 AM
I previously did a script which gets the correct selection order by recording the selection history into a text file, it might point you in the right direction. The function is imbedded in a script that generates a cv curve from selected points.

http://forums.cgsociety.org/showthread.php?t=455797

Robert Bateman
04-14-2007, 08:39 AM
I executed it and nothing happened.Can you please explain,what exactly scriptCtx is and how it is used?

The command has created a new tool object called attachTool. To use that tool, simply call

setToolTo attachTool;

the attachTool will now remain resident in maya until you close it, so no need to re-run the script each time. To kill the tool, use :

deleteUI attachTool;

the ls command only returns the correct selection order for objects, with components the only *nice* way to do it is to create a specific tool context (scriptCtx, draggerCtx etc)

CGTalk Moderation
04-14-2007, 08:39 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.