Substance Painter
In this start to finish texturing project within Substance Painter we cover all the techniques you need to texture the robot character.
# 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.
# 2 22-03-2010 , 12:07 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
The reason why that is happening, is because `ls -sl` returns an array of objects, not a single object. A nasty way to get around this, I say nasty as there are much "cleaner" ways to do it, but since you know that there will always be only one object in the selection list at a time, you can do this:

$spotList = `ls -sl`;
$spot = $spotList[0];

This will only use the first object in your selection array.

You will also get into trouble with your code to assign the colors to your spotlight. You can fix this by doing this:

setAttr ($spot + ".color") -type double3 $colorR $colorG $colorB;

Hope this help you out mate.


Imagination is more important than knowledge.
# 3 22-03-2010 , 06:43 AM
Falott's Avatar
Registered User
Join Date: Jan 2005
Location: vienna
Posts: 1,095
oh man! I wish my life was that easy sometimes. thx alot mate, worked perfectly fine.


everything starts and ends in the right place at the right time.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads