T_T Can anyone help me please. Modify a Script

Ive been trying to modify this script
its a script that generates material ids into an selected objects in max
the problem is it only works on 'vray materials'
ive was trying to modify it into a 'standard material' but i cant get it to work
can anyone help me please
I would really appreciate anyone.
I have attach the script.

sorry for my bad english

random_material_id_original.ms9.67 KB