need help: combining multiple selected shaders to one

need help: combining multiple selected shaders to one

arch.yossi
Explorer Explorer
1,410 Views
3 Replies
Message 1 of 4

need help: combining multiple selected shaders to one

arch.yossi
Explorer
Explorer

yup, can't find anywhere how to preform this simple task: I'm playing with Maya and imported models sometimes have tones of phongs etc., most are the same. many are assigned to invisible objects to the camera. How can I simply merge them to one shader ? e.g., selecting 100 phongs in the Hypershade (that are assigned to all sort of objects) and make them one shader assigned to all those objects, not searching one by one but automatically via script or something like that ? thanks !! 

0 Likes
Accepted solutions (1)
1,411 Views
3 Replies
Replies (3)
Message 2 of 4

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

This Python script should do what you want:

import maya.cmds as mc
def reassignIdenticalShaders():
    shaders = mc.ls(sl = True)
    remainingShader = shaders.pop(0)
    
    for shd in shaders:
        mc.select(cl = True)
        mc.hyperShade(o = shd)
        mc.hyperShade(a = remainingShader )
        mc.delete(shd)
    
reassignIdenticalShaders()

Just select the shader you want everything to be connected to first and then all the other shaders that are identical to it and run the script from a Python tab in the scripteditor.

The script will then reassing all objects connected to the other shaders to the first one in the selection and delete the other shaders.

 

I hope it helps!

Message 3 of 4

arch.yossi
Explorer
Explorer

wow great I'm gonna try it today !!!

0 Likes
Message 4 of 4

arch.yossi
Explorer
Explorer

man thanks a lot !!!

that's great it solved a lot of headaches to me !!!