Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script for Phong material that the specularcolor and color are already set

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
713 Views, 4 Replies

Script for Phong material that the specularcolor and color are already set

Hello guys! I'm new with MEL scripting, been trying to create this simple script without any help from the forum. But I really can't. 
So I was trying to create a script that will create a phong material and the specular color and color is already set.

The script is working, it is creating a new phong material but the specular color and color is not changing at all. 
I hope I'm making sense with my questions and I hope you guys can help.

Cheers! 

here's my script right now: 

shadingNode -asShader phong;

string $selMat[] = `ls -sl`;

for ($mat in $selMat)
{
    //sets -renderable true -noSurfaceShader true -empty -name phong4SG;
    //connectAttr -f phong4.outColor phong4SG.surfaceShader;
    setAttr "phong4.color" -type double3 0.0909091 0.0909091 0.0909091 ;
    setAttr "phong4.specularColor"     -type double3 0.937063 0.937063 0.937063 ;
}

 

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

I dont know how to put the currently selected material here

    setAttr "phong4.color" -type double3 0.0909091 0.0909091 0.0909091 ;
    setAttr "phong4.specularColor" -type double3 0.937063 0.937063 0.937063;

"phong"(currently selected material)".color" 

if I'm correct I think that will solve my problem maybe? 

Message 3 of 5
mspeer
in reply to: Anonymous

Hi!

 

string $selMat[] = `ls -sl`;

for ($mat in $selMat)
{
    //sets -renderable true -noSurfaceShader true -empty -name phong4SG;
    //connectAttr -f phong4.outColor phong4SG.surfaceShader;
    setAttr ($mat + ".color") -type double3 0.0909091 0.0909091 0.0909091 ;
    setAttr ($mat + ".specularColor") -type double3 0.937063 0.937063 0.937063 ;
}

 

Message 4 of 5
Anonymous
in reply to: mspeer

You save my ass fam! 🙂 
The script is working, it creates a phong material with the set values for specular and color.

but my problem right now is if i run this script the material should already applied to my selected mesh.
I tried to used -forceElement and other stuff but I failed.

and also if you know a tutorial that can help me with this pls tell me. 

Thanks a lot brother! you really save my time 🙂 

Message 5 of 5
Anonymous
in reply to: Anonymous

already got it fam! thank you for helping mee!

string $matNew = `shadingNode -asShader phong`;
setAttr ($matNew + ".colorR") 0.0909091;
setAttr ($matNew + ".colorG") 0.0909091;
setAttr ($matNew + ".colorB") 0.0909091;
setAttr ($matNew + ".specularColor") -type double3 0.937063 0.937063 0.937063 ; 
sets -renderable true -noSurfaceShader true -empty -name ($mat + "SG");
    
global proc assignMat( string $matNew )
{
    hyperShade -assign $matNew;
}

select $sel;
assignMat ($matNew)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report