Last active
August 30, 2024 13:46
-
-
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 hidden or 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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot. I need to duplicate the shading network. And I use the code cmds.duplicate([mtl, mtl_sg], upstreamNodes=True). It really works. Thanks for your reply.