-
Notifications
You must be signed in to change notification settings - Fork 2
/
cycleThroughVisibleCamerasBackward.py
44 lines (35 loc) · 1.58 KB
/
cycleThroughVisibleCamerasBackward.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Author : HYUK KO | [email protected] | github.com/kohyuk91
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 == "forward":
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 == "backward":
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])
if __name__ == "__main__":
main("backward")