Trouble with selection

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2004
Question Trouble with selection

/*Hi

I am in trouble about selection.
I created a window and two different button and one float slider.
I can connect single selection with this float. But when I select two objects I can't connect selection with the float slider.

Try this
Select a locator click select button and than click connect button. Now change the slider value. This is work.
Select two locators click select button and than click connect button. Now change the slider value. This isn't work.

I use this code -> {"locator1", "locator2"}; for defining two objects. I have a problem here.
But I don't know how can I solve this problem.
Can you help me ?

Thanks

*/


window;
columnLayout;
rowColumnLayout -nc 3 -cw 1 200 -width 500 ;
textField -tx "" -w 250 tf01;
button -l "Select" -c "sel";
button -l "Connect" -c "con";
floatSliderGrp -min -50 -max 50 -v 0 -f true -cw2 45 45 -w 30 sld_lm;
setParent;
showWindow;
global proc sel()
{
string $sel[] = `ls -sl`;
if((size($sel) > 2) || (size($sel) == 0))
warning " Equinox Warning : You must select object(s) between 1 and 2";
else
{
if(`size($sel)` == 1)
{
//Get Name - Connection
string $getname = ( $sel[0] );
textField -e -tx $getname tf01;
}
else
{
if(`size($sel)` == 2)
{
//Get Name - Connection
string $getname = ( "{" + "\"" + $sel[0] + "\"" + ", " + "\"" + $sel[1] + "\"" + "}" );
textField -e -tx $getname tf01;
}
else
{
}
}
}
}
global proc con()
{
$htRA = ".ry";
$htOb = (`textField -q -tx tf01`);
floatSliderGrp -e -min -50 -max 50 -v 0 -f true -cw2 45 45 -w 30 sld_lm;
connectControl sld_lm ( $htOb + $htRA );
}
 
  01 January 2004
Hello. Been having a play with the script. Is there a reason you have the string formatted like that?
It'd easier if you could pass the selection to the con function as is, or get the selection inside the con function and then interate through it.... Not sure if that's something you want to do...

Alternatively, you could use some crazy match expression to strip out the names... I've had a bit of a play with match, but haven't come up with anything that will extract the names yet. Don't even know if that is possible with match...

Ahhh that's where Perl is handy
__________________


Last edited by Jhavna : 01 January 2004 at 03:11 PM.
 
  01 January 2004
Hi equinox,

Here's a fix that has the advantage of working on any number of selections.


global proc sel()
{
string $sel[] = `ls -sl`;
if(size($sel) == 0)
warning " Equinox Warning : Holistic selection... check connection between chair and keyboard.";
else
{
string $getname;
for ($a in $sel)
$getname += $a + " ";
textField -e -tx $getname tf01;
}
}

global proc con()
{
string $htRA = ".ry";
// tokenize has to see $htOb as an expressly declared string
string $htOb = (`textField -q -tx tf01`);
string $temp[];
tokenize $htOb $temp;
string $param;
for ($a in $temp)
$param += $a + $htRA + " ";
floatSliderGrp -e -min -50 -max 50 -v 0 -f true -cw2 45 45 -w 30 sld_lm;
eval("connectControl sld_lm " + $param);
}
 
  01 January 2004
Hi

I am creating lots of textfield for each object now.
@sbp
But now I can go on with your code .


Thank you very much for yours help
 
  01 January 2006
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



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 01:39 AM.


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