Thanks Aerilius!!, the information i got is pure gold, you made me realize the error of checking every face with the same material is a waste of time, also yes the index was not working at all.
The idea here is to have a very complex model with many materials and rename the materials like this: prop_bed_mat_01, prop_bed_mat_02, and so on, keeping instances, when i export to unreal I combine the meshes, meaning i collapse all the faces, components, groups into 1 single object, its easier to handle 1 obj with a million faces than 1 million objects with 1 face, realtime works better with single objects.
Your approach (btw thanks is working not like mine :)), renames the materials per each component inside a group, this is a problem because i might have 1 group with 20 components, props from the web are highly unorganized, now i am getting prop_bed_mat-0-15, prop_bed_mat-1-15, prop_bed_mat-3-15, also i tried it in the bed (practical example), and it freezes sketchup.
Maybe the approach is wrong?, what if we build an array of the mats names of the selection and then simply rename those mats? is it possible in the api to grab materials names and then rename them?