Created
June 11, 2019 09:05
-
-
Save BigRoy/02bd17ce5dd55f5f5056bf0fdb105384 to your computer and use it in GitHub Desktop.
Simple example of how to get shader assignment overrides in renderlayers in Maya. (This is built for renderlayers, *not!* for render setup)
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 cmds | |
def get_shader_overrides_in_renderlayer(layer): | |
"""Return shader assignment overrides in renderlayer""" | |
attr = "{layer}.outAdjustments".format(layer=layer) | |
indices = cmds.getAttr(attr, multiIndices=True) | |
overrides = {} | |
for index in indices: | |
index_attr = "{0}[{index}]".format(attr, index=index) | |
# For each adjustment check whether we have a valid out plug | |
# connection for which the override is intended. (In some | |
# rare cases a disconnected override index remains to exist) | |
connections = cmds.listConnections(index_attr + '.outPlug', | |
shapes=True) | |
if connections: | |
node = connections[0] | |
out = cmds.listConnections(index_attr + '.outValue')[0] | |
overrides[node] = out | |
return overrides | |
for layer in mc.ls(type="renderLayer"): | |
print get_shader_overrides_in_renderlayer(layer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment