maya Finding scene objects Using ls() to see if an object exists


Example

Since ls() finds objects by names, it's a handy way to find out if an object is present in the scene. ls() with a list of objects will only return the ones which are in the scene.

 available_characters = cmds.ls('fred', 'barney', 'wilma', 'dino')
 # available_characters will contain only the named characters that are present