Skip to content

Instantly share code, notes, and snippets.

@splinecraft
Created December 5, 2018 18:27
Show Gist options
  • Save splinecraft/99f29bdbcc19a71d0e9548bb122af4d6 to your computer and use it in GitHub Desktop.
Save splinecraft/99f29bdbcc19a71d0e9548bb122af4d6 to your computer and use it in GitHub Desktop.
duplicates current cam and flips it horizontally. from https://pastecode.xyz/view/b7c34dda#L19
import maya.cmds as mc
def createMirrorCam(currentCam):
mirrorCam_grp = mc.group(empty=True,n="mirrorCam_grp")
mc.addAttr(mirrorCam_grp, ln="notes", dt="string", sn="nts")
mc.setAttr("%s.notes"%mirrorCam_grp, currentCam,type="string")
mirrorCam = mc.duplicate (currentCam,n="mirrorCam")
camPos = mc.xform(mirrorCam[0], ws=1, t=1, q=1)
camRot = mc.xform(mirrorCam[0], ws=1, ro=1, q=1)
mc.xform(mirrorCam_grp, ws=1, t=(camPos[0], camPos[1], camPos[2]),ro=(camRot[0], camRot[1], camRot[2]))
mc.parentConstraint(currentCam,mirrorCam_grp)
mc.setAttr("%s.scaleX"%(mirrorCam_grp),-1)
mc.parent(mirrorCam,mirrorCam_grp,a=1)
mc.setAttr("mirrorCam.rx", lock=False)
mc.setAttr("mirrorCam.ry", lock=False)
mc.setAttr("mirrorCam.rz", lock=False)
mc.setAttr("mirrorCam.sx", lock=False)
mc.setAttr("mirrorCam.sy", lock=False)
mc.setAttr("mirrorCam.sz", lock=False)
mc.setAttr("mirrorCam.rx", 0)
mc.setAttr("mirrorCam.ry", 0)
mc.setAttr("mirrorCam.rz", 0)
mc.setAttr("mirrorCam.sx", 1)
mc.setAttr("mirrorCam.sy", 1)
mc.setAttr("mirrorCam.sz", 1)
mc.lookThru('mirrorCam')
currentCam =mc.lookThru(q=1)
if currentCam == "mirrorCam":
mc.lookThru(mc.getAttr("mirrorCam_grp.notes"))
mc.delete("mirrorCam_grp")
else:
sel = mc.ls(sl=1)
if mc.objExists("mirrorCam_grp"):
mc.delete("mirrorCam_grp")
createMirrorCam(currentCam)
mc.select(sel)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment