How can I get the renderlayer and renderlayer collections for an asset in Maya?

How can I get the renderlayer and renderlayer collections for an asset in Maya?

Peteman12
Advocate Advocate
1,192 Views
1 Reply
Message 1 of 2

How can I get the renderlayer and renderlayer collections for an asset in Maya?

Peteman12
Advocate
Advocate
I want to know if it's possible to use python to determine what render layers/render layer collections an asset is part of, so I can assign them to a different asset. editRenderLayerMembers only applies to the renderlayer, whereas I want to take an asset, and see what render layers it's a part of.
0 Likes
1,193 Views
1 Reply
Reply (1)
Message 2 of 2

muir.j
Contributor
Contributor

Yeah I wanted to do this a while ago and couldn't find a function for it. so ended up crawling through the renderSetup structure.  Hopefully this may help a little.

 

import maya.app.renderSetup.model.renderSetup as renderSetup

rs = renderSetup.instance()   
children = rs.getChildren()
for layer in children:    
    renderLayerName = layer.name()
    print 'Layer :', renderLayerName

    collections= layer.getCollections()
    for collection in collections:
        print 'Collection :', collection.name(), 'Length :', len(collections)
        selector = collection.getSelector()

        #Set collection filter to All (0) - this is an enum
        selector.setFilterType(0)
        staticNames = selector.getStaticNames()
        staticNames = list(staticNames)
        for i in staticNames:
            print i