-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcreateLayoutCamera
More file actions
85 lines (75 loc) · 3.35 KB
/
Copy pathcreateLayoutCamera
File metadata and controls
85 lines (75 loc) · 3.35 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# SGL create layout camera
# Modifies selected camera with shotCam defaults or creates one if no camera selected
# Checks for renderable cameras, alerts
# Checks for existing shotCams and sets layout attributes
# If shotCam does not exist, creates a camera and sets its attributes
def checkRenderCamera():
renderableList=[]
for x in cmds.ls(typ='camera',l=True):
if cmds.getAttr(x+'.renderable'):
renderableList.append(x)
ll=len(renderableList)
if ll==0:
print "RenderCamera: There is no renderable camera!\n",
return 0
if ll>1:
print "RenderCamera: More than one render camera detected!\n",
cmds.confirmDialog(m="There is more than one camera selected to render!\n\nIf this is unexpected, fix it and and try again.", b="OK", icn="information", t="Alert")
return 1
else: # if ll==1
camSelect = []
camSelect = renderableList[0].split("|")
defaultCamList = ["persp", "top", "front", "side", "back", "right", "left", "bottom"]
for cam in defaultCamList:
if cam == camSelect[1]:
print "RenderCamera: Looks like you've got a default camera selected to render:", camSelect[1], "\n",
cmds.confirmDialog(m="Render Camera: " + camSelect[1] + "\nThis looks like one of the default cameras.\nIf this is unexpected, fix it and and try again.", b="OK", icn="information", ma="center", t="PRC Alert")
return 1
print "Your renderable camera is: ", camSelect[1], "\n",
return 1
def setLayoutAttrs():
layoutAttrStr = "\nRenderable: True\nHorizontalFilmAperture: 0.937007874\nVerticalFilmAperture: 0.5275590551\nOverscan: 1.3\nNearClipPlane: 1\nOrthographicWidth 10\nDisplayResolution: 1\n"
print "Setting layout attribtes:\n"+ layoutAttrStr
cmds.setAttr( 'shotCamShape.renderable', 1)
cmds.setAttr( 'shotCamShape.horizontalFilmAperture', 0.937007874)
cmds.setAttr( 'shotCamShape.verticalFilmAperture', 0.5275590551)
cmds.setAttr( 'shotCamShape.overscan', 1.3)
cmds.setAttr( 'shotCamShape.nearClipPlane', 1)
cmds.setAttr( 'shotCamShape.orthographicWidth', 10)
cmds.setAttr( 'shotCamShape.displayResolution', 1)
checkRenderCamera()
def newShotCam():
print "Creating shotCam\n"
newCamera = cmds.camera()
cmds.rename(newCamera[0], "shotCam")
setLayoutAttrs()
# start here
shotCam = cmds.ls(sl=True)
if cmds.nodeType(shotCam) == 'transform':
dagNode = cmds.listRelatives(shotCam, s=True, c=True)[0]
if cmds.nodeType(dagNode) == 'camera':
if "shotCamShape" in str(dagNode):
setLayoutAttrs()
else:
allCams = cmds.ls(type = "camera")
if "shotCam" in str(allCams):
print "shotCam transform not selected, select shotCam..."
else:
print "Creating shotCam"
newShotCam()
else:
allCams = cmds.ls(type = "camera")
if "shotCam" in str(allCams):
print "shotCam transform not selected, select shotCam..."
else:
result = cmds.confirmDialog(
title='shotCam',
message='Create shotCam?',
button=['OK', 'Cancel'],
defaultButton='OK',
cancelButton='Cancel',
dismissString='Cancel')
if result == "OK":
print "Creating shotCam"
newShotCam()
#msb 13032020