Hi all,
I just started learning maya python. I was trying to make a script which will create a render layer, add all selected geometries to it and assign a shader. I am having problem in assigning a shader to the selected mesh as i tried directly. Then i read in some forums that a shader cannot be connected directly. Can you guys please help me with this.
So all i want is to connect an already existing shader which was not created from the script and rather it was imported from a location, to the selected mesh.
Also i would like to know how to do a material override on the render layer for this same scenerio.
Maya Python - Assign Material to Selected Geo
Karthikkumar
#1
DrWeeny
#2
You may have to make the renderlayer wanted as “current renderlayer” then assign the shader with hypershade command. If you try to connect with connectAttr, you should look how the connections are done with the node graph.
haggi
#3
Materials are not assigned directly to a geometry. The whole material thing works with shadingGroups, what is nothing else but sets. So if you can find out the shading group of your shader (in most cases the node which is connnected to the outColor of a shader), and if you have the geometry (e.g. meshes) you can do it with (from memory, didnt’t try it):
sets -e -forceElement $geo $shadingGroup;
kiryha
#4
You may download Shader manager (or other tools) and explore the code, may be you will find some more useful examples there.