From John Turello, 1 Month ago, written in Plain Text.
Embed
  1. import maya.cmds as mc
  2.  
  3. def createMirrorCam(currentCam):
  4.     mirrorCam_grp = mc.group(empty=True,n="mirrorCam_grp")
  5.     mc.addAttr(mirrorCam_grp, ln="notes", dt="string", sn="nts")
  6.     mc.setAttr("%s.notes"%mirrorCam_grp, currentCam,type="string")
  7.     mirrorCam = mc.duplicate (currentCam,n="mirrorCam")
  8.     camPos = mc.xform(mirrorCam[0], ws=1, t=1, q=1)
  9.     camRot = mc.xform(mirrorCam[0], ws=1, ro=1, q=1)
  10.     mc.xform(mirrorCam_grp, ws=1, t=(camPos[0], camPos[1], camPos[2]),ro=(camRot[0], camRot[1], camRot[2]))
  11.     mc.parentConstraint(currentCam,mirrorCam_grp)
  12.    
  13.     mc.setAttr("%s.scaleX"%(mirrorCam_grp),-1)
  14.     mc.parent(mirrorCam,mirrorCam_grp,a=1)
  15.    
  16.     mc.setAttr("mirrorCam.rx", lock=False)
  17.     mc.setAttr("mirrorCam.ry", lock=False)
  18.     mc.setAttr("mirrorCam.rz", lock=False)
  19.     mc.setAttr("mirrorCam.sx", lock=False)
  20.     mc.setAttr("mirrorCam.sy", lock=False)
  21.     mc.setAttr("mirrorCam.sz", lock=False)
  22.    
  23.     mc.setAttr("mirrorCam.rx", 0)
  24.     mc.setAttr("mirrorCam.ry", 0)
  25.     mc.setAttr("mirrorCam.rz", 0)
  26.     mc.setAttr("mirrorCam.sx", 1)
  27.     mc.setAttr("mirrorCam.sy", 1)
  28.     mc.setAttr("mirrorCam.sz", 1)
  29.        
  30.     mc.lookThru('mirrorCam')
  31.  
  32. currentCam =mc.lookThru(q=1)
  33.  
  34. if currentCam == "mirrorCam":
  35.     mc.lookThru(mc.getAttr("mirrorCam_grp.notes"))
  36.     mc.delete("mirrorCam_grp")
  37. else:
  38.     sel = mc.ls(sl=1)
  39.     if mc.objExists("mirrorCam_grp"):
  40.         mc.delete("mirrorCam_grp")
  41.     createMirrorCam(currentCam)
  42.     mc.select(sel)