PDA

View Full Version : Trouble with selection


safakoner
01-28-2004, 02:17 PM
/*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 );
}

Jhavna
01-28-2004, 03:09 PM
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 ;)

sbp
01-29-2004, 09:55 AM
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);
}

safakoner
01-29-2004, 10:05 AM
Hi

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


Thank you very much for yours help :bounce:

CGTalk Moderation
01-17-2006, 08:00 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.