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") |
Is there any way to duplicate the shading node with all connectiones in maya cmds?
Is there any way to duplicate the shading node with all connectiones in maya cmds?
Matching these menu entries:
The logic is roughly:
Duplicate Shading Network
from maya import cmds
cmds.duplicate(upstreamNodes=True)
Duplicate without network
from maya import cmds
cmds.duplicate()
Duplicate with connections to network
from maya import cmds
cmds.duplicate(inputConnections=True)
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Many thanks