Last active
May 18, 2022 02:22
-
-
Save tokejepsen/c674146a5565893b9085898fef005377 to your computer and use it in GitHub Desktop.
Maya: Get Attribute On Renderlayer
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 pymel.core | |
drg = pymel.core.PyNode('defaultRenderGlobals') | |
# iterate over the selected renderlayers. | |
# can select renderlayers through the outliner with "Display" > "DAG Objects Only" | |
data = {} | |
render_cams = [] | |
for layer in pymel.core.ls(selection=True, type='renderLayer'): | |
layer_data = {} | |
render_cams = [] | |
if layer.adjustments.get(multiIndices=True): | |
for count in layer.adjustments.get(multiIndices=True): | |
if not layer.adjustments[count].plug.connections(): | |
continue | |
if layer.adjustments[count].plug.connections()[0] == drg: | |
attr = layer.adjustments[count].plug.connections(plugs=True)[0] | |
layer_data[attr.name(includeNode=True)] = layer.adjustments[count].value.get() | |
for cam_attr in layer.adjustments[count].plug.connections(plugs=True, type='camera'): | |
if cam_attr.endswith('renderable') and layer.adjustments[count].value.get() == 1.0: | |
render_cams.append(pymel.core.PyNode(cam_attr.split('.')[0]).getParent()) | |
layer_data['renderpasses'] = layer.connections(type='renderPass') | |
else: | |
layer_data['renderpasses'] = layer.connections(type='renderPass') | |
layer_data['cameras'] = render_cams | |
data[layer.name()] = layer_data | |
print data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment