Skip to content

Instantly share code, notes, and snippets.

@BigRoy
Created August 28, 2019 16:55
Show Gist options
  • Save BigRoy/653379bd3b0b1c2f6d85d50d05addf29 to your computer and use it in GitHub Desktop.
Save BigRoy/653379bd3b0b1c2f6d85d50d05addf29 to your computer and use it in GitHub Desktop.
Fix Maya legacy renderlayer being unable to duplicate (it doesn't show up correctly, but it does create a new renderLayer node visible when Show DAG nodes only is disabled)
# Fix Maya bug where you cannot duplicate a renderlayer correctly bug
# This is with Legacy Renderlayers, not Render Setup.
# Bug has been found in both Maya 2018 + 2019
import maya.cmds as mc
# Recreate all renderlayer overrides (.adjustments)
for layer in mc.ls(type="renderLayer"):
attr = layer + ".adjustments"
indices = mc.getAttr(attr, multiIndices=True) or []
connections = []
for index in indices:
# Collect current connection
index_attr = "{plug}[{index}]".format(plug=attr, index=index)
src = cmds.listConnections(index_attr + ".plug",
source=True,
plugs=True)[0]
value = cmds.getAttr(index_attr + ".value")
connections.append((src, value))
# Remove the entry and break any connections
mc.removeMultiInstance(index_attr, b=True)
# Recreate the overrides
for i, (src, value) in enumerate(connections):
cmds.connectAttr(src, layer + ".adjustments[{0}].plug".format(i))
@RocketeerVFX
Copy link

RocketeerVFX commented Oct 2, 2020

It ran this time but sadly no joy. :/

Force renderlayer editor refresh

mel.eval('updateEditorRenderLayer "RenderLayerTab"')
Fixing missing renderLayerId connection for: BTY_ASIA1
prop_bridge:renderLayerManager.renderLayerId[2] -> BTY_ASIA1.identification
Fixing missing connection to defaultRenderingList for: BTY_ASIA1
BTY_ASIA1.message -> defaultRenderingList1.rendering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment