This seems to do that [in very limited testing]. It requires that:
1. the edges you want to Dimension between always run in orthogonal directions;
2. the edges are all Lines or Polylines [top-level ones, i.e. not nested in Blocks];
3. the edges are all separate objects from each other [it won't work to dimension a closed-Polyline rectangle];
4. no edge, if a Polyline, has some other part that comes closer to the picked point than the expected Dimension location [e.g. by turning a corner, or within an arc segment at the expected location];
5. there are no other Lines or Polylines between the picked point and the edges [there can be other kinds of things].
(defun C:DBW (/ find pt ptE ptN ptW ptS); = Dimension Both Ways
(defun find (ang / n found)
(setq n 0)
(while (not (setq found (ssget "_C" pt (polar pt ang (setq n (1+ n))) '((0 . "LINE,*POLYLINE"))))))
(ssname found 0)
); defun
(setq
pt (getpoint "\nPoint through which to Dimension Both Ways: ")
ptE (vlax-curve-getClosestPointTo (find 0) pt)
ptN (vlax-curve-getClosestPointTo (find (/ pi 2)) pt)
ptW (vlax-curve-getClosestPointTo (find pi) pt)
ptS (vlax-curve-getClosestPointTo (find (* pi 1.5)) pt)
); setq
(command
"_.dimlinear" "_non" ptE "__non" ptW "@"
"_.dimlinear" "_non" ptN "__non" ptS "@"
); command
(princ)
); defun
It uses whatever Dimension Style is current, and on the current Layer, so set those first; they could be built into the routine if desired.
Kent Cooper, AIA