(setq Width (getdist "\nWidth of area to be filled : "));Getting the total Width of the area to fill
(setq Height (getdist "\nHeight of area to be filled : "));Getting the total Height of the area to fill
(setq PanelWidth (getdist "\nWidth of the panel : "));Getting Width of the panel
(setq PanelHeight (getdist "\nHeight of the panel : "));Getting Height of the panel
(setq XNumberOfPanels (fix (/ Width PanelWidth)));Calculating Number of panels in X Direction
(setq YNumberOfPanels (fix (/ Height PanelHeight)));Calculating Number of panels in Y Direction
(setq Gap (/(- Width (* XNumberOfPanels PanelWidth)) (+ XNumberOfPanels 1)));Calculating Gap between the panels
(setq Pnt (getpoint "\nPick the Bottom Left Corner of the area to be filled : "));Getting the insertion Point
(setq YPnt Pnt)
(setq x 0);Counter for X Direction
(setq y 0);Counter for Y Direction
(setq COSMode (getvar 'OSMODE));Storing the value of Current OSMode
(setvar 'OSMODE 0);Switching Off all Object snaps
(setq Pnt (List (+ (car Pnt) Gap) (+ (cadr Pnt) Gap)));Computing the starting point of the first Rectangle, which is away by one Gap distance along X and one Gap distance along Y