title: Maya , render layers, and instances in Python 2.7
body: <p>I have several render layers with different random names. Each render layer has a lights instance in it. I need to remove this instance.</p>
  <p><img src="https://i.stack.imgur.com/zLSWB.png" alt="Screengrab to show the instance" /></p>
  <p>This is as far as I've got:</p>
  <pre><code>import maya.app.renderSetup.model.override as override
  import maya.app.renderSetup.model.selector as selector
  import maya.app.renderSetup.model.collection as collection
  import maya.app.renderSetup.model.renderLayer as renderLayer
  from maya.app.renderSetup.model.renderSetup import instance
  
  import maya.cmds as cmds
  
  rs = instance()
  
  #this creates a render layer called MyRenderSetupLayer
  rl = rs.createRenderLayer(&quot;MyRenderSetupLayer&quot;)
  
  #This creates a lights collection instance inside the created render layer
  l1 = rl.lightsCollectionInstance()
  
  #deletes the lights collection instance in the render layer
  collection.delete(l1)
  </code></pre>
  <p>The last line is the one that deletes the lights instance in the created render layer, so I know you can do it. My issue is that I don't know how to assign a variable (like l1) to an existing lights collection instance so I can then delete it.</p>
  <p>If I try and see what type is l1, I get</p>
  <blockquote>
  <p>&lt;class 'maya.app.renderSetup.model.collection.LightsCollection'&gt;</p>
  </blockquote>
  <p>I have always different names in my render layers, but even if I did, I can't figure out how to delete those instances, unless I created them in that script, as they are assigned to a variable and then I can just delete it like that. But since these files were created by different people, my current workflow doesn't work.</p>
  <p>Thanks so much! I appreciate it</p>