A different approach, embedded into a context that will do all closed 4-vertex lightweight Polylines you choose, all at once. And you can choose them with windowing, fence, lasso, individual picks, etc., and it will "see" only the qualifying objects among the selection -- no error from picking the wrong kind of thing.
(vl-load-com)
(defun C:RCL (/ ss n pl i); = Rectangle Corner Labels
(if (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 4) (-4 . "&") (70 . 1))))
(repeat (setq n (sslength ss))
(setq
pl (ssname ss (setq n (1- n)))
i 0
); setq
(foreach x '(0 1 3 2)
(command "_.text" "_mc" (vlax-curve-getPointAtParam pl x) "" ""
(strcat "P" (itoa (setq i (1+ i))))
); command
); foreach
); repeat
); if
(prin1)
)
It uses the current Text Style [assumed to not have a fixed height] and height, on the current Layer, but specifics for those could be built in.
It would even be possible to check each Polyline for whether it is, in fact, rectangular, if desired.
Kent Cooper, AIA