Subdividing surface into predefined equal rectangle


I am looking to devide a surface into equal rectangles so they fit as best they can on said surface.


This particular example is a large surface with two doors generated from a single point on axis (0, 0, 0)
I would like to fit a maximum of rectangles with dimensions (880mm, 1300mm) inside this boundary.

Any Ideas? Attached is the grasshopper script.script (13.2 KB)