Assign this shader to this object?


#1

I want al cones in my scene to be assigned a premade surface shader: “MAT_cones_red”

All cones are just called pCone# so

'pCone*'

will do for the selection.

Thanks in advance


#2

materials aren’t directly assigned to models, materials are connected to sets, and the sets collect meshes.

find the shadingGroup connected to your material and use the “sets” command to add your cones.


#3

Using sets command:

import pymel.core as pm

# enter you shading group name
# select objects to asign shaders, run
list = pm.ls( sl = 1 )
for i in list:
    pm.sets('shading group name', forceElement = i)

Here is same topic:
http://tech-artists.org/forum/showthread.php?1279-Assigning-a-Material-using-Pymel

If you need to work with shaders often, i have some ready to use solutions for this (shader asignment part can be used with any render engine):
http://www.kiryha.blogspot.com/2014/02/render-notes.html