Arnold General Overrides

This script will easily to on and off various common Arnold settings. It will set up layer overrides automatically when your current layer is not the default layer

Current Options: Matte Object, Auto Bump, and Opaque. (If you would like any options added feel free to email me on my contact page and request them.)

To Run: Select the geometry and make sure you are on the desired render layer. Run the script. Select the options you would like to be affected. Then choose the on or off button.

#Arnold Overrides version 1.0.0
#For Maya. Tested in Maya 2014 & 2015 with Arnold 4.2.9.0
#Bryanna London www.bryannalondon.com
#!/usr/bin/env python

import maya.cmds as cmds

#Define Selected Geo
selGeo = cmds.ls(selection = True , visible = True , type = 'transform')

#Turn Matte Objects On
def turnOn():

    #Define Current Render Layer
    rl = cmds.editRenderLayerGlobals( query=True, currentRenderLayer=True )
    #Get Query Values
    matteValue, opaqueValue, bumpValue = queryingValues()

    if selGeo > 0:

        if matteValue == True:

            if rl == 'defaultRenderLayer':

                for geo in selGeo:

                    cmds.setAttr(geo + '.aiMatte' , 1)
            else:

                 for geo in selGeo:

                    cmds.editRenderLayerAdjustment(geo + '.aiMatte')
                    cmds.setAttr(geo + '.aiMatte' , 1)

        if opaqueValue == True:

            if rl == 'defaultRenderLayer':

                for geo in selGeo:

                    cmds.setAttr(geo + '.aiOpaque' , 1)
            else:

                 for geo in selGeo:

                    cmds.editRenderLayerAdjustment(geo + '.aiOpaque')
                    cmds.setAttr(geo + '.aiOpaque' , 1)

        if bumpValue == True:

            if rl == 'defaultRenderLayer':

                for geo in selGeo:

                    cmds.setAttr(geo + '.aiDispAutobump' , 1)
            else:

                 for geo in selGeo:

                    cmds.editRenderLayerAdjustment(geo + '.aiDispAutobump')
                    cmds.setAttr(geo + '.aiDispAutobump' , 1)           

    else:

        cmds.confirmDialog(title='Confirm', message='Nothing Selected. Nothing Done.' , button =['Ok'])

#Turn Matte Objects Off
def turnOff():

    #Define Current Render Layer
    rl = cmds.editRenderLayerGlobals( query=True, currentRenderLayer=True )
    #Get Query Values
    matteValue, opaqueValue, bumpValue = queryingValues()

    if selGeo > 0:

        if matteValue == True:

            if rl == 'defaultRenderLayer':

                for geo in selGeo:

                    cmds.setAttr(geo + '.aiMatte' , 0)
            else:

                 for geo in selGeo:

                    cmds.editRenderLayerAdjustment(geo + '.aiMatte')
                    cmds.setAttr(geo + '.aiMatte' , 0)

        if opaqueValue == True:

            if rl == 'defaultRenderLayer':

                for geo in selGeo:

                    cmds.setAttr(geo + '.aiOpaque' , 0)
            else:

                 for geo in selGeo:

                    cmds.editRenderLayerAdjustment(geo + '.aiOpaque')
                    cmds.setAttr(geo + '.aiOpaque' , 0)

        if bumpValue == True:

            if rl == 'defaultRenderLayer':

                for geo in selGeo:

                    cmds.setAttr(geo + '.aiDispAutobump' , 0)
            else:

                 for geo in selGeo:

                    cmds.editRenderLayerAdjustment(geo + '.aiDispAutobump')
                    cmds.setAttr(geo + '.aiDispAutobump' , 0)

    else:

        cmds.confirmDialog(title='Confirm', message='Nothing Selected. Nothing Done.' , button =['Ok'])

#delete window if a window already exisits
if cmds.window('overridesWindow', exists=True):
    cmds.deleteUI('overridesWindow')

#Create Window
def createGUI():
    #window set up
    overridesWindow = cmds.window('overridesWindow',title="Custom Render Elements", rtf=True)
    cmds.columnLayout(adjustableColumn= True, rowSpacing= 3)
    cmds.checkBox('matteObj',label= "Matte Object", value=False)
    cmds.checkBox('opaque',label= "Opaque", value=False)
    cmds.checkBox('autobump',label= "Auto Bump", value=False)
    cmds.rowColumnLayout(numberOfRows = 1)
    cmds.button( label='TURN ON', width= 112, command=('turnOn()'))
    cmds.button( label='TURN OFF', width= 112, command=('turnOff()'))
    cmds.setParent('..')
    cmds.columnLayout()
    cmds.button( label='Close', width= 224, command=('cmds.deleteUI(\"' + overridesWindow + '\", window=True)'))
    cmds.setParent('..')
    cmds.setParent('..')
    cmds.showWindow('overridesWindow')

#Query Values
def queryingValues():

    matteValue = cmds.checkBox('matteObj', query = True, value = True)
    opaqueValue = cmds.checkBox('opaque', query = True, value = True)
    bumpValue = cmds.checkBox('autobump', query = True, value = True)
    return matteValue, opaqueValue, bumpValue

#Create GUI
createGUI()

© 2016 Bryanna London

Advertisements