View Single Post
# 4 06-03-2015 , 06:28 AM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
"..when I try to convert the string that holds the name of the attribute to a float value, it always tells me that it equals zero"

Float variables only store numerical values. Converting a string "123" to float will work but converting "apple" won't. So make sure your dealing with the variable for the light intensity and not the light name.

Code:
string $mySel[] = `ls -sl`;
string $myShapeSel[] = `ls -selection -dag -lf -ap`;
string $name;
string $shapeNode;
string $shapeNodeIntensity;

float $testing;
int $arraySize = `size $mySel`;

//Gen~ obj variable could have just as easily been swapped out for shapeNode
// instead of declaring it above
for ($shapeNode in $myShapeSel) {
//Gen~ now you can ditch this ---> $obj = $shapeNode;
setAttr $shapeNode + ".intensityMult"; //Gen~ set intensityMult to what value?
$testing = (float)$shapeNodeIntensity; //Gen~ shapeNodeIntensity never had a value
// so nothing to convert
print $testing;
}
for ($i = 0; $i < $arraySize; $i++) {
$name = $mySel[$i];
//$shapeNode = $myShapeSel[$i];
//$myShapeSel[$obj] = $shapeNode;
//$shapeNodeIntensity = ($shapeNode + ".intensityMult");
//$testing = $shapeNodeIntensity;


//Gen~ selecting PLC to add attributes is unessecary
// simply add the name of the object you want the command to alter
// at the end of the statement --> addAttr -ln ($name) -at double -k 1 PLC;
select -r PLC; 

addAttr -ln ($name) -at double -k 1;
//print $shapeNode;

}


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::