View Single Post
# 1 21-03-2010 , 10:19 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095

getAttr and setAttr in an array

lets say I have a pointlight I want to query the colorRGB values from and copy those values into a spotlights colorRGB.
(I need to use an array because a have a few hundred lights later on). currently one light is selected with RGB of 4 4 4




{

$selected = `ls -sl`;

for( $node in $selected ) {

$colorR = `getAttr ($node + ".colorR")`;
$colorG = `getAttr ($node + ".colorG")`;
$colorB = `getAttr ($node + ".colorB")`;


print ( $colorR +" " );
print ( $colorG +" " );
print ( $colorB +"\n" );


CreateSpotLight;
//create new spotlight and paste above RGB values to it

$spot = `ls -sl`;
//guess this new selection list creates interfering problems with 1st selection list, but how else can I select these new items?

setAttr ($spot + "Shape.colorR") ($colorR);
setAttr ($spot + "Shape.colorG") ($colorG);
setAttr ($spot + "Shape.colorB") ($colorB);

}

print $selected;


};
4 4 4
defaultSpotLight(1, 1,1,1, 0, 40, 0, 0, 0, 0,0,0, 1, 0);
// Error: line 23: Cannot convert data of type string[] to type string. //



user added image


everything starts and ends in the right place at the right time.

Last edited by Falott; 21-03-2010 at 04:35 PM.