If you can count on always selecting an actually rectangular Polyline, and want the largest internal Circle drawn, something like this? [untested]:
(vl-load-com); in case needed
(defun C:CMR ; = Circle at Midpoint of Rectangle
(/ rec)
(setq
rec (car (entsel "\nRectangle to draw Circle in the middle of: "))
dim1 (/ (distance (vlax-curve-getStartPoint rec) (vlax-curve-getPointAtParam rec 1)) 2)
dim2 (/ (distance (vlax-curve-getPointAtParam rec 1) (vlax-curve-getPointAtParam rec 2)) 2)
); setq
(command "_.circle"
"_non"
(mapcar '/
(mapcar '+ (vlax-curve-getStartPoint rec) (vlax-curve-getPointAtParam rec 2))
'(2 2 2)
); mapcar /
(min dim1 dim2); radius
); command
(princ)
); defun
That leaves the distances you want in the 'dim1' and 'dim2' variables.
It could be made to verify that you selected a Polyline, that it's closed and with 4 vertices, and even check whether it's rectangular (I have code for that if you want).
Kent Cooper, AIA