PDA

View Full Version : Replace phong1 with material called brdf0


Hamburger
06-29-2010, 11:59 AM
I'm trying to replace phong1 with a material called brdf0, then phong2 with a material called brdf1, phong3 with brdf2, phong4 with brdf3 etc....

Not sure how to go about this though:

global proc vrsceneImport()

{
string $materials[] = `ls -materials`;

for ( $mat in $materials )
{

string $type = `nodeType $mat`;
if ($mat != "lambert1")
if ($mat != "shaderGlow1")
if ($type != "particleCloud")
if ($mat !="VrayMtl")
{
string $origMat = $mat;
string $new = "brdf0";

replaceNode $origMat $new;
delete $origMat;
rename $new $mat;
}
}
}

This code replaces the first of many materials first then stalls. I know it's this line:

string $new = "brdf0";"

But I'm really cannibalising scripts here and am pretty much stuck. If anyone could help in what to do that would be most appreciated. :beer:

Baalz
06-29-2010, 12:27 PM
Haven't had the time to test but I think your problem is the multiple "if"s chained together.

It would be easier to write :

global proc vrsceneImport()

{
string $materials[] = `ls -materials`;

for ( $mat in $materials )
{

string $type = `nodeType $mat`;
if ($mat != "lambert1" && $mat != "shaderGlow1"
&& $type != "particleCloud" && $mat !="VrayMtl")
{
string $origMat = $mat;
string $new = "brdf0";

replaceNode $origMat $new;
delete $origMat;
rename $new $mat;
}
}
}

Hope that helps,
Baalz

NaughtyNathan
06-29-2010, 01:22 PM
checking node types is often redundant if you are only interested in a particular type or types of node because you can just do this:

string $phongs[] = `ls -type "phong"`;


also, is there any guarentee Maya will return the names in sequence order, does that matter? are the numeric indicies really important..?

you could just do this:

select -r -ne `ls "phong*"`;to select all the phongs then type:

brdf0

into the rename input box on your top status line area.

:nathaN

Hamburger
06-30-2010, 03:52 AM
Thank you guys for the help.

also, is there any guarentee Maya will return the names in sequence order, does that matter? are the numeric indicies really important..?

Yes - it is critical because I'm converting a V-Ray Max scene to Maya via two external formats:

FBX which imports placeholder materials as phongs as phong1, phong2 etc...
Then I import a vrscene file into Maya which only imports the propoer materials as brdf0, brdf1 etc...

Anyway, I will try this tonight and see if I can get it to work. Cheers again.

CGTalk Moderation
06-30-2010, 03:53 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.