Skip to content

Instantly share code, notes, and snippets.

@kohyuk91
Created September 8, 2019 12:28
Show Gist options
  • Select an option

  • Save kohyuk91/3bcbed49c48b8f13d2ea9bb683a441be to your computer and use it in GitHub Desktop.

Select an option

Save kohyuk91/3bcbed49c48b8f13d2ea9bb683a441be to your computer and use it in GitHub Desktop.
# lookThruVisCam.py
#
# Author : HYUK KO / [email protected]
'''
import lookThruVisCam
lookThruVisCam.main("next")
'''
'''
import lookThruVisCam
lookThruVisCam.main("previous")
'''
import maya.cmds as mc
import maya.OpenMaya as om
import maya.OpenMayaUI as omui
def main(mode):
selVisCamShapeList = mc.ls(cameras=True, visible=True, long=True)
selVisCamShapeListSize = len(selVisCamShapeList)
panelWithFocus = mc.getPanel(withFocus=True)
activeView = omui.M3dView.active3dView()
camDagPath = om.MDagPath()
activeView.getCamera(camDagPath)
currentCam = camDagPath.fullPathName()
if selVisCamShapeListSize == 1:
if currentCam == '|persp|perspShape':
mc.lookThru(panelWithFocus, selVisCamShapeList[0])
else:
mc.lookThru(panelWithFocus, '|persp|perspShape')
elif mode == "next":
if currentCam not in selVisCamShapeList:
mc.lookThru(panelWithFocus, selVisCamShapeList[0])
else:
if selVisCamShapeList.index(currentCam) == selVisCamShapeListSize - 1:
mc.lookThru(panelWithFocus, selVisCamShapeList[0])
else:
mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) + 1])
elif mode == "previous":
if currentCam not in selVisCamShapeList:
mc.lookThru(panelWithFocus, selVisCamShapeList[0])
else:
if selVisCamShapeList.index(currentCam) == 0:
mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeListSize - 1])
else:
mc.lookThru(panelWithFocus, selVisCamShapeList[selVisCamShapeList.index(currentCam) - 1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment