CGTalk > Software Specific Forums > Autodesk Maya > Maya Programming
To minimize the ads you see on this page create a CGTalk account and log in HERE
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 11-09-2011, 06:24 PM   #1
GearSpinner
New Member
portfolio
J
SF, USA
 
Join Date: May 2010
Posts: 13
scriptCtx: issues with selection sets

Hey all,

I'm having some issues with the scriptCtx command in MEL. I'm trying to make a tool that chains together some functions that perform some operations on a list of objects. My selection sets don't seem to be working at all.

At the end of the scriptCtx, it does call the functions I have listed, but the contents of the selections are wrong. In addition, the second set will not accept a single object alone, I press enter and nothing happens until I select 2 or 3. Then, testProcB prints the wrong set of objects, to boot!

So clearly I'm doing something crazy wrong here

This is what I'd like to accomplish:

Press a button in a UI
User selects a set of objects and presses Enter
Objects are added $Selection1

User selects another set of objects presses Enter
Objects are added to $Selection2

$Selection1 is passed to testProcA
do some things to objects in $Selection1

$Selection1 is passed to testProcB
do some things to objects in $Selection2

and so on until the end of the chain (set to 2, currently)...


Here's my code and thanks for reading.
Code:
proc testProcA(string $a[]) { for ($object in $a) { print("In Selection A: "+$object +"\n"); } } proc testProcB(string $a[]) { for ($object in $a) { print("In Selection B: "+$object +"\n"); } } if (`contextInfo -exists chainTest`) deleteUI chainTest; window; columnLayout; button -c "setToolTo chainTest" chainTest; showWindow; scriptCtx -title "chainTest" -totalSelectionSets 2 -finalCommandScript "testProcA($Selection1); testProcB($Selection2);" -setNoSelectionPrompt ("1: Select objects") -setSelectionPrompt ("1: Select more and hit ENTER") -setAutoToggleSelection false -setAutoComplete false -setSelectionCount 0 -setNoSelectionPrompt ("2: Select objects") -setSelectionPrompt ("2: Select more and hit ENTER") -setAutoToggleSelection false -setAutoComplete false -setSelectionCount 0 chainTest;
 
Old 11-13-2011, 01:56 AM   #2
GearSpinner
New Member
portfolio
J
SF, USA
 
Join Date: May 2010
Posts: 13
Update:

Well I was able to get this to work the other day, finally, but not exactly the way I intended. I ended up using two scriptCtx calls, and calling the second from the procedure started by the the first.

I found it was important to use evalDeferred("setToolTo yourScriptCtx;") when calling scriptCtx from inside a function like this, or you may get bad results. In my case, it caused Maya to crash :o

I wanted to post this solution in case anyone runs into a problem like this. Maybe somebody will find it useful. I don't know if this is the best way, but it worked for me.

Code:
proc testProcA(string $a[]) { for ($object in $a) { print("In Selection A: "+$object +"\n"); evalDeferred("setToolTo chainTestB;"); select -cl; } } proc testProcB(string $a[]) { for ($object in $a) { print("In Selection B: "+$object +"\n"); select -cl; } } if (`contextInfo -exists chainTestA`) deleteUI chainTestA; if (`contextInfo -exists chainTestB`) deleteUI chainTestB; window; columnLayout; button -c "setToolTo chainTestA" chainTestA; showWindow; scriptCtx -title "chainTestA" -totalSelectionSets 1 -finalCommandScript "testProcA($Selection1)" -setNoSelectionPrompt ("1: Select objects") -setSelectionPrompt ("1: Select more and hit ENTER") -setAutoToggleSelection false -setAutoComplete false -setSelectionCount 0 chainTestA; scriptCtx -title "chainTestB" -totalSelectionSets 1 -finalCommandScript "testProcB($Selection1)" -setNoSelectionPrompt ("2: Select objects") -setSelectionPrompt ("2: Select more and hit ENTER") -setAutoToggleSelection false -setAutoComplete false -setSelectionCount 0 chainTestB;

Last edited by GearSpinner : 11-13-2011 at 01:59 AM. Reason: code copypasta correction
 
Old 11-13-2011, 01:56 AM   #3
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:29 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.