A script that divide a map in squares

Hi all,

I have to cut a game map (quite big) in order to get a “puzzle” of squares (that are equals).
I tried to do it manually with the knife tool but it’s not very precise. So I decided to write a script that would do it for me. I used the “Blender Knife Tool” script, and I added some functions but now I get crazy results while dividing my map.

Can someone take a look at the script ?

Here is the blend file.
Currently the script just tries to cut the object in "columns and not squares.

Thanks !

Wetneb.