UVW mapping to corrected normals

Hi all

I have a 3d model from an architect that contains hundreds of simple cube objects that represents houses,

The problem I have is that i need to texture up each house, I have found a script that can apply UVW maps to an array of selected objects however the Xform on each of the boxes is out, and if I apply a UVW map to any box it applies it but rotated 90 degrees off, I need a script that allows me to assign a UVW map that fits to the geometry perfectly,

If one already exists I would appriciate having the link, or if somone wants to get in touch about writing this I can send them a sample scene over with a view to cost up what i am looking for if anyone out there is interested.

Kind Regards
Mark Miles