batch replace materials

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2011
batch replace materials

Hey guys ,

i have a scene file imported from max that has tones of phong materials and i wanna batch replace all the materials to Lambert .

string $shaderNode = "material name here . .";
string $replaceWith = `createNode "lambert"`;
replaceNode $shaderNode $replaceWith;
delete $shaderNode;
rename $replaceWith $shaderNode;

this script is working fine however every time i try to run a for loop on this it does`t work ;
here is the one with the for loop

string $sel[] = `ls -sl`; string $use;
for ($use in $sel){
string $shaderNode = "matMetalBluef";
string $replaceWith = `createNode "lambert"`;
replaceNode $shaderNode $replaceWith;
delete $shaderNode;
rename $replaceWith $shaderNode;
}


Any help will be greatly appreciated !
thanks,
__________________
Ahmed Yousry
ayousry@gmail.com

Last edited by Ayousry : 01 January 2011 at 11:49 PM.
 
  01 January 2011
what's matMetalBluef here?
 
  01 January 2011
Thumbs up

Ok, got it, but This code works well with me, I've three objects with one blinn "matMetalBluef" assigned to all of'em, but if you have different objects with different materials assigned to each object, this code might not work.

Also, there's one more issue with this code, it replaces only material node, so now wrong material node is attached to wrong shadingGroup node.

Download the file attached and run your code and tell me what exactly you want...
Attached Files
File Type: zip matMetalBluef_test.zip (20.9 KB, 5 views)
 
  01 January 2011
hey dushyantk
my script only work with one material, it doe`t work when u select multiple materials .
my scene has tones of materials that imported from max and they all come with high reflective phong shaders .
__________________
Ahmed Yousry
ayousry@gmail.com
 
  01 January 2011
That is awesome...

Found this in documentations, I think this is what you exactly want. Try this command:

deleteShadingGroupsAndMaterials;

...
__________________
Dushyant Kumar Kashyap.
http://programmerslimbo.blogspot.com/
 
  01 January 2011
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:00 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.