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

Material Replace

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
Anonymous
12837 Views, 12 Replies

Material Replace

Hello! I'm a native C4D user trying to transition to Maya. In C4D, I can alt-drag a material on top of another to replace/overwrite that material everywhere in a scene. Is there an easy way to do this sort of thing in Maya? Maybe something to do with replacing node connections? No idea... Any help is greatly appreciated.

 

I need a quick method for this because my workflow often requires receiving sketchup models that have multiple shades of colors and I need a quick way of consolidating these... NEED to use maya for Unreal export capabilities.

12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: Anonymous

middle mouse button, drags nodes shaders and most things in maya, welcome to the maya super race. Oh and if you don't know anything about maya, its unstable as balls, save, save and save some more.

Message 3 of 13
joostkonemann
in reply to: Anonymous

You can do this in multiple ways (as most things in Maya), though one easy way is:

 

In the Hypershade, right-click and hold on a material and choose "Select Objects With Material". Right-click and hold on the material you want to assign and choose "Assign Material To Selection".

--
MacBook Pro 13,3 - 2.7GHz - 16GB - Radeon Pro 460 - macOS Catalina 10.15
Message 4 of 13
Anonymous
in reply to: joostkonemann

thanks guys. i've heard of the 'select objects with material' 'assign material to selection' method before, but i need something with fewer clicks/movements. what do you mean by middle mouse click? which outputs do i connect?

 

also, back to the many material problem - are there any scripts that can overwrite multiple materials with one? or is there a way to select object assignments of multiple materials at once and reassign those to one material? again, i often get tons of grey colors from sketchup which should just be one grey. this would make it so much easier than having to recreate the materials in unreal when i export. thanks

Message 5 of 13
Anonymous
in reply to: Anonymous

Can you send me a small sample scene, I'll try script something for you but cant promise ill get it right. I'm not confident, this will be deep under the hood with tons of connections to be broken and made, why not just do it in C4D and then export your mesh obj/fbx to maya.
Message 6 of 13
Anonymous
in reply to: Anonymous

I suggest you move this to maya programming, you'll get better help there.
Message 7 of 13
joostkonemann
in reply to: Anonymous

The MEL script is quite easy (maybe it can be done in a more efficient way, but this works):

 

$target = `ls -sl -tl 1`;
select -tgl $target;
$selection = `ls -sl`;
for ($material in $selection) {
hyperShade -objects $material;
hyperShade -assign $target;
}

 

Select the materials you want to replace, select the target material last and run the script.

With the optimize scene command in the file menu you can afterwards remove all unused shading nodes.

--
MacBook Pro 13,3 - 2.7GHz - 16GB - Radeon Pro 460 - macOS Catalina 10.15
Message 8 of 13
Anonymous
in reply to: joostkonemann

Awesome. I will try this after work (this is for a freelance project).

 

Also, I would do this in C4D, but the way C4D exports doesn't work correctly for UE4. I've narrowed it down to a material problem, as C4D saves FBX with its multiple material tags (a C4D specific thing), and UE4 overwrites them all with a single material. I've been working on a python script for it, but my programming skills are limited, so I've found it easier to learn Maya.

Message 9 of 13
Anonymous
in reply to: Anonymous

I was thinking that you go from C4D to maya via FBX. But if that script
works then it's all good. I'm also very new to scripting don't really know
python that well but I can get around.
Message 10 of 13
Anonymous
in reply to: joostkonemann

Great script! Totally works. One thing. Is there a way to add an undo just in case I do something stupid? My monkey brain does funny things sometimes that I regret and undos really help to counteract it (if only they were included in real life as well). 

 

I've tried the C4D through maya thing before, but sometimes it imports a little weird, so I figure why not just learn Maya and join the masses who both worship and hate the all-powerful Autodesk?

Message 11 of 13
joostkonemann
in reply to: Anonymous

With two extra lines the complete script can be undone in one go:

 

undoInfo -ock;

$target = `ls -selection -tail 1`;

select -tgl $target;

$selection = `ls -sl`;

for ($material in $selection) {

hyperShade -objects $material;

hyperShade -assign $target;

}

undoInfo -cck;

--
MacBook Pro 13,3 - 2.7GHz - 16GB - Radeon Pro 460 - macOS Catalina 10.15
Message 12 of 13
Anonymous
in reply to: joostkonemann

You're awesome. Thanks

Message 13 of 13
yanyangox3
in reply to: joostkonemann

wow!! 

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

Post to forums  

Autodesk Design & Make Report