[Maya]Replace Shaders quickly and easily?

Heya,

Disclaimer: I do not really have a clue about maya. either usage-wise (beyond the very basics that is) nor on the scripting side (also beyond the very basics of using mayapy or maya.cmds a bit). Hence the question(s) might look stupid to a seasoned user.

I have a big scene referencing various other scenes via maya’s referencing system. It also references its shaders from maya files (one file per shader). I am round-tripping this scene with Max and am currently concerned with getting things back up in maya. So what i need to do is iterate over all shaders and replace them with the original shaders from the external .mb files.

How would i best go about this? Can i replace the shaders? or do i need to iterate over objects and assign the old shaders? Can this be done without loading the references?

Any input would be really appreciated!

Regards,
Thorsten

In Maya, materials, and what they map to, are two different nodes.

Like this:
Texture > Shader > ShadingGroup > Mesh1, Mesh2, Face1, Face2, etc…

The ShadingGroup contains the list of all faces and meshes that need to be assigned to the connected shader. you can swap the shader out really easily using connectAttr command.

when the meshes come back from Max, they will probably have a new shadingGroup and a new material. Get your original material and just connect it to the new shadingGroup.

Thanks i will take a look!

you’ll probably be surprised to note that the usual method of assigning a shading group is to use the ‘sets’ command, since shading groups are really specialized versions of sets. As @rgkovach said, the returned files probably already have groups set up so youll just be connecting the OutColor attribute of the shader balls to the SurfaceShader attribute of the shading groups. You can add objects or components to the shading groups with the ‘sets’ command.