Last active
February 26, 2024 03:14
-
-
Save mfessenden/71e2166c16fbcf7e8cf8 to your computer and use it in GitHub Desktop.
Maya command to create a lambert shader & shading group node named for the object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as mc | |
def applyMaterial(node): | |
if mc.objExists(node): | |
shd = mc.shadingNode('lambert', name="%s_lambert" % node, asShader=True) | |
shdSG = mc.sets(name='%sSG' % shd, empty=True, renderable=True, noSurfaceShader=True) | |
mc.connectAttr('%s.outColor' % shd, '%s.surfaceShader' % shdSG) | |
mc.sets(node, e=True, forceElement=shdSG) | |
applyMaterial("pSphere1") |
Many thanks
Many thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For anyone else who came here through google search in a lazy moment and just wanted the code quickly create a material with the shading engine here's the code for solely the creation without assigning or checking whether material exists.
And thus for example to create the shader, change the color and then assign it:
Just putting that here so that on my next google search I can be even lazier!