This is a quick-n-dirty based on the code CAB posted, provided that the room is NOT rotated.
(defun c:cgrid ( / )
(vl-Load-Com)
(prompt "\nPick points, starting with lower left-most corner of the room. Enter when done.")
(if (setq pt1 (getpoint))
(progn
(setq elast (entlast))
(command "PLINE" pt1 (setq pt2 (getpoint pt1)))
(while (setq pt2 (getpoint pt2 "\nNext point: ")) (command pt2))
(command "")
)
)
(setq en (entlast)
elist (entget en)
ptlist (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) elist)))
(setq max_x (apply 'max (mapcar 'car ptlist))
min_x (apply 'min (mapcar 'car ptlist))
max_y (apply 'max (mapcar 'cadr ptlist))
min_y (apply 'min (mapcar 'cadr ptlist)))
(setq snpbase (list ( + (/ (- max_x min_x) 2) min_x)( + (/ (- max_y min_y) 2) min_y)))
(command "snapbase" snpbase)
(command "_hatch" "u" "0" "24" "y" en "")
(command "snapbase" "0,0")
)
I'll work on doing the same thing, should the room be rotated, by using the method I described above. I'll have the user draw the polyline, if it's at an angle, rotate it to 0, find the center, place the hatch, rotate it all back.