-
Notifications
You must be signed in to change notification settings - Fork 0
/
Render.py
55 lines (42 loc) · 1.69 KB
/
Render.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
45
46
47
48
49
50
51
52
53
54
55
# common render settings GUI
import maya.cmds as cmds
import maya.mel as mel
from functools import partial
# get render globals
curr_rl = cmds.editRenderLayerGlobals( query=True, currentRenderLayer=True )
curr_width = cmds.getAttr('defaultResolution.width')
curr_height = cmds.getAttr('defaultResolution.height')
def UI():
"""generates simple button UI"""
# check to see if window exists
if (cmds.window('render', exists=True)):
cmds.deleteUI('render')
# create window
window = cmds.window('render', title='Render', w=120, h=300, mxb=False, mnb=False, sizeable=False)
# create layout
main_layout = cmds.columnLayout(w=120, h=300)
cmds.separator(h=15)
cmds.columnLayout()
cmds.button(label='Render', w=120, h=30, command=partial(render, curr_rl, curr_width, curr_height))
cmds.button(label='Render Square', w=120, h=30, command=partial(render, curr_rl, 1024, 1024))
cmds.button(label='Render AO', w=120, h=30, command=partial(render, 'ao', 1024, 1024))
cmds.setParent('..')
cmds.separator(h=15)
cmds.showWindow(window)
def render(rl, width, height, *args):
"""
renders the scene with the given attributes
keyword args:
width -- width of render image in pixels
height -- height of render image in pixels
*args -- additional args
"""
dar = width / float(height)
cmds.setAttr('defaultResolution.deviceAspectRatio', dar)
mel.eval('RenderViewWindow')
cmds.Mayatomr(preview=True, layer=rl, xResolution=width, yResolution=height, camera='perspShape')
editor = 'renderView'
cmds.renderWindowEditor(editor, e=True, si=True)
def main():
"""calls the UI function to generate the UI"""
UI()