FORUMS: list search recent posts

Melscript getAttr color

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Jacqueline Johnsen
Melscript getAttr color
on Feb 18, 2013 at 8:36:10 pm

After hours trying to get this script to work and finnaly noticing I had a : instead of a ; I'm still stuck with this script. I'm starting to think what I want isn't possible, so plx confirm if so.

print(getAttr("SkinMat.color"));
float $color = `getAttr SkinMat.color`;
setAttr("LipsMat.color", $color);

So I simply want to take the color settings of a material and transfer it to another material. The script will be placed under a "neutral" button in a melscript GUI.
The orignal script is:sphere -name "Brawl";
print(getAttr("Brawl.scaleY"));
float $ys = `getAttr Brawl.scaleY`;
setAttr("Brawl.scaleY", $ys *2);

This script only works with the one "y" value, so that might be my problem? I could use the HSV to RGB node, but I'd rather not as I'm having problems with my high quality render viewport which I need to use to show my project (the texture will turn black in this view).

Any help will as usuall be greatly apreciated. ^^
J.

Wishing it could be just: setAttr "LipsMat.color" `getAttr SkinMat.color`;


Return to posts index


Lee Marsland
Re: Melscript getAttr color
on Feb 20, 2013 at 7:00:48 pm

I'm sure there is an easier way to do this/ not as many lines, but I don't have time to look into that right now, sorry, this worked for me

$colorR = `getAttr SkinMat.colorR`;
$colorG = `getAttr SkinMat.colorG`;
$colorB = `getAttr SkinMat.colorB`;
setAttr("LipsMat.colorR", $colorR);
setAttr("LipsMat.colorG", $colorG);
setAttr("LipsMat.colorB", $colorB);


or

$colorR = `getAttr SkinMat.colorR`;
$colorG = `getAttr SkinMat.colorG`;
$colorB = `getAttr SkinMat.colorB`;
setAttr("LipsMat.color", $colorR, $colorG, $colorB);


Return to posts index


Steve Sayer
Re: Melscript getAttr color
on Mar 1, 2013 at 8:39:37 pm

Hi, Jacqueline.

Lee's response should work. The reason you're having a problem is that your getAttr is returning either a vector or a string array, while your setAttr is expecting a series of float values separated by spaces.

So you CAN do:

setAttr "LipsMat.color" 0 0.5 1;
But you CAN'T do:

vector $v = <<0, 0.5, 1>>;
setAttr "LipsMat.color" $v;

And you also can't do:

float $f[] = {0, 0.5, 1};
setAttr "LipsMat.color" $f;

The most compact way I can think of to write your code is like this:

vector $neutral = `getAttr "SkinMat.color"`;
setAttr "LipsMat.color" ($neutral.x) ($neutral.y) ($neutral.z);

You capture the color information as a vector, then refer to the vector's components specifically one at a time so the setAttr command knows what to do with them.

Hope that helps.


Return to posts index


Jacqueline Johnsen
Re: Melscript getAttr color
on Mar 2, 2013 at 10:23:34 am

Awesome, it works. ^^ I had some problems with the placement of the variable, since I wanted it incorperated in my melscript gui and I tought it had to be at the beginning of the script but the solution to that was quite simple:

proc buttonNaturalLips()
{ vector $neutralLips = `getAttr "SkinMat.color"`;
setAttr "LipsMat.color" ($neutralLips.x) ($neutralLips.y) ($neutralLips.z);}


Thank you both!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]