I said that cube is consist of 6 surfaces, just in purpose of explanation..in order to reach total number surfaces of your cube, or any other mesh, use CountSurfaces(cube), eg.
Total_Surfaces=CountSurfaces(cube)..then you will know how many surfaces you actually have and then trough for...next loop access each of them and do your brush painting stuff..
Total_Surfaces=CountSurfaces(cube)..then you will know how many surfaces you actually have and then trough for...next loop access each of them and do your brush painting stuff..