rollout AssignRandomMaterial_rollout "Please Input A Name" ( edittext Object_name "" button assign_materials "ASSIGN MATERIALS..." on assign_materials pressed do --MAIN AIM: Clear selection so no objects are selected and then select all the objects beginning with the name the user input (Object_name) ( clearselection() --clear selection so nothing selected Execute ("$'"+Object_name+"*'") --select the objects beginning with the inputted name )--end on --MAIN AIM: Select all materials beginning with the name the user input (Object_name) and then select a random one function getMaterials ( --Object_materials = get all material slots using (Object_name+"*") --select random Object_materials ) --MAIN AIM: Loop around the selection adding a random material (hence the function getMaterials) sel = selection as array count = 1 undo on ( if sel.count > 0 then ( while count <= sel.count do ( select sel[count] count += 1 $.material = getMaterials() ) ) ) )--end rollout createDialog AssignRandomMaterial_rollout 250 50