title: how should i get the shape node of imagePlane connected to camera in maya
body: <pre><code>def connectedImgPlanes(self,dagNode):
      print "dagNode ",dagNode ,type(dagNode)
      sourceConnections = cmds.listConnections(dagNode, source = True) or []
      if len(sourceConnections) != 0:
         lc = sourceConnections[0].split("-&gt;")[1]
         atribVal=cmds.getAttr(lc+".imageName")
         return atribVal
      else:
          return ""
  </code></pre>
  
  <p>the above function works and returns the path with file name from the imageName attribute of shape node of imageplane, but if top camera has imageplane set then the above function doesnt work, in that case i get error saying <em># Error: line 1: IndexError: file  line 1: list index out of range #</em> due to</p>
  
  <pre><code>newStr=str(sourceConnections[0]).split("-&gt;")[1]
  </code></pre>
  
  <p>and then I tried different way to get the shape node of the imageplanes and return an attribute from it,</p>
  
  <pre><code>    lc=""
      try:
          lc=cmds.listRelatives(cmds.listRelatives(dagNode)[0])[0]
      except TypeError:
             return ""
      print lc
      atribVal=cmds.getAttr(lc+".imageName")
      return atribVal
  </code></pre>
  
  <p>this one also works until we add the top camera and the code starts giving a different type of error saying <em>More than one object matches name: imagePlane1 #</em> </p>
  
  <p>please some one help me out get the shape nodes of each camera and return empty string if camera has no imageplane set...</p>