Last active
September 20, 2016 09:49
-
-
Save patwooky/60b50e9c580bedb12c920760894b5d56 to your computer and use it in GitHub Desktop.
Getting connected shader and objects from a shader
This file contains 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
# Written by Patrick Woo | |
# [email protected] | |
from pymel.core import * | |
def getShaders(): | |
for shEngine in ls(type='shadingEngine'): | |
print 'shading engine:', shEngine | |
for connection in [x for x in shEngine.listConnections()]: | |
myType = nodeType(connection,i=True) | |
if ('shadingDependNode' in myType or 'THdependNode' in myType): | |
# found a shader, printing it out | |
print '\t<shader> ->', connection, '(%s)'% nodeType(connection) | |
for connection in sets(shEngine,q=True): | |
# prints out the list of members that the shader is assigned to | |
print '\t<dagNode> ->',connection, '(%s)'% nodeType(connection) | |
print '' | |
getShaders() | |
This file contains 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
# Written by Patrick Woo | |
# [email protected] | |
from pymel.core import * | |
''' | |
this is a second method, leveraging one Maya's behavior of when you select a shadingEngine node by code (python or mel) | |
Maya will select shape nodes in the scene that are assigned to the that shading group. | |
''' | |
for shEngine in ls(type='shadingEngine'): | |
print 'shading engine:', shEngine | |
for connection in sets(shEngine,q=True): | |
print '\t->', connection, '(%s)' % nodeType(connection) | |
print '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment