PDA

View Full Version : Selection pb!


Nicool
04-24-2003, 12:00 AM
How to select only the lights of a selection??

string $lights[]=`ls -sl -lt`;

:beer:

gmask
04-24-2003, 12:23 AM
ls -sl -type light

Nicool
04-24-2003, 10:04 AM
It doesn't work anymore :rolleyes:

string $lights[]=`ls -sl -type light`;

for ($light in $lights) {
$lightIntensity = `getAttr ($light+".intensity")`;
$lightIntensity = $lightIntensity + 0.1;
setAttr ($light+".intensity") $lightIntensity;
}

If there is not -sl all lights are modified. But I want modify only the intensity of the selected lights.
Help me !

X-Tender
04-24-2003, 01:00 PM
hmm i'am not sure but you can try something like this


$selection[] = `ls -sl`;
$lights[] = `ls -type light`;
for($i=0;$i<size($selection);$i++)
{
for($j=0;$j<size($lights);$j++)
{
if ($selection[i] == $lights[j])
{
$lightIntensity = `getAttr ($lights[j]+".intensity")`;
$lightIntensity = $lightIntensity + 0.1;
setAttr ($lights[j]+".intensity") $lightIntensity;
};
};
};


:D

Nicool
04-24-2003, 01:16 PM
_Yes, I've think to do something like this... But It's a bit heavy for the simple action it is.

_Have you got an idea to use to array??
A first array : the selection.
A second array : the light in the first array (so in the slection).

_I think the ls function should be a bit more sofisticated :annoyed:

X-Tender
04-24-2003, 02:17 PM
k .. here is an another solution to get all lights in your selection into an array


$selection = `ls -sl`;
select -r `listTransforms -lights`;
$alllights = `ls -sl`;
select -r $selection;
select -d $alllights;
$other = `ls -sl`;
select -r $selection;
select -d $other;
$lights = `ls -sl`;


Have Fun!

gmask
04-24-2003, 05:52 PM
Try this..

pickWalk -d down;
string $lights[]=`ls -sl -type light`;
for ($light in $lights) {
$lightIntensity = `getAttr ($light+".intensity")`;
$lightIntensity = $lightIntensity + 0.1;
setAttr ($light+".intensity") $lightIntensity;
}

CaptainSam
04-24-2003, 08:58 PM
or simply

pickWalk -d down;
for ($light in `ls -sl -type light`)
{setAttr ($light+".intensity") (`getAttr ($light+".intensity")` + 0.1); }

saves you a few lines of code.

gmask
04-24-2003, 09:07 PM
Originally posted by CaptainSam
or simply

pickWalk -d down;
for ($light in `ls -sl -type light`)
{setAttr ($light+".intensity") (`getAttr ($light+".intensity")` + 0.1); }

saves you a few lines of code.

Nice one.. never occured to that the ls statement could be included inside the for command.

Nicool
04-24-2003, 10:59 PM
1001 thanks... I'm a bit sad because it's not my script now:shrug:

gmask
04-25-2003, 12:10 AM
Originally posted by Nicool
1001 thanks... I'm a bit sad because it's not my script now:shrug:

Don't be sad.. you'll learn alot by lookign at other people's scripts. I love finding new ways to make them shorter so I learned something today as well..cool!

Nicool
04-25-2003, 11:11 AM
Thanks to all the cgtalkers who had helped me!


// Description : choose a positive or a negative value to add to the lights of the selection intensity.

global proc mliUI() {

$result=`promptDialog
-title " ! modifyLightIntensity"
-message " Enter a positive or negative value: "
-button "Ok"
-button "Cancel"
-defaultButton "Ok"
-dismissString "Cancel"`;

if ($result == "Ok") {
modifyLightsIntensity(promptDialog -q);
}
}

global proc modifyLightsIntensity(float $value) {

pickWalk -d down;
string $lights[]=`ls -sl -lt`;

for ($light in $lights) {
$lightIntensity = `getAttr ($light+".intensity")`;
$lightIntensity = $lightIntensity + $value;
setAttr ($light+".intensity") $lightIntensity;
}

print ("Selected lights intensity modified by " + $value);
}


!-!-! Would you correct my english for the last sentence in the code "by":beer:

alexx
04-25-2003, 11:28 AM
Originally posted by Nicool
1001 thanks... I'm a bit sad because it's not my script now:shrug:

if that would be true, i would nearly never have made my "own" scripts..

why inventing the wheel a second time, when you can reuse something someone else made before? - the only thing that really counts is that u understand what you do.. the rest does not matter and no one will ask about it ever :)

cheers

alexx

Nicool
04-25-2003, 09:40 PM
Thanks for your advices alexx and gmax. You are true:beer:

CGTalk Moderation
01-15-2006, 12: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.