rectangle to window script

I tried to mess with these scripts…with no luck. In fact I made it worse all together.

Credits go to the orignial author Chris Johnson. But can someone help me modify these scripts so they work…I have client you needs a million windows…and I have a million rectangles…
You’ll find the orginal files here. http://www.d3cg.com/vray/scripts/
Thanks in advance!
Corey