Selecting multiple objects and applying attribute using python in maya


I’m a new·bie in programming and always get stuck at functions, for loops, pretty much everything… @_@ …
I was hoping that somebody can help me to create a script that can "select multiple objects and apply “HoldOut” attribute to all of them at one click.

This is what I came up with so far…
Mainly… just creating a window with the option buttons…

import maya.cmds as cmds

def selAll(*args):
    list =,p=True, path=True), r=True)

def hold(*args):
    checkList =

def holdoutWindow():
    if cmds.window('HoldOutWindow', exists=True):
    bigMainWindow = cmds.window('HoldOutWindow', t= 'Hold Out Geos', sizeable=True, mnb=False, mxb=False)
    cmds.columnLayout(adj=True, rowSpacing =5)
    cmds.button( label="Select All Geometry", command=selAll)
    cmds.button( label="Hold Out ON/OFF", command=hold)
    cmds.separator(h=10, style='none')    
    cmds.button(label = 'CLOSE', command = closingWindow)
    cmds.showWindow( bigMainWindow )
def closingWindow(arg=None):
    cmds.deleteUI('HoldOutWindow', window =True)

Thanks !