Search code examples
pythonmayamel

How to know current Renderable cameras in Maya using Mel command or python script


I want to know the information of Renderable Camera of layers using MEL command or python in MAYA.

MEL code for Render layers:

$layers = 'ls -type "renderLayer"';

This code gives me render layers but I want Renderable Camera too.Please help me

Expected Output

Layer           Camera

Defaultlayer    Layout_camera:masterCam
second_layer    Layout_camera:masterCam

I have got the Layer but i have stuck on the camera's part.


Solution

  • This code gives me render layers and camera .

    $layers = `ls -type "renderLayer"`;
    
    for( $layer in $layers )
       {    
         print($layer);
         print("\n");
    
         editRenderLayerGlobals -currentRenderLayer $layer;
    
         string $cameras[] = `ls -type camera`;
    
         for ($camera in $cameras)
         { 
            if (getAttr ($camera+".renderable"))
                print ($camera+"\n");
         }
    }