Hi,
Here's a LISP I wrote some times ago.
It draws a leader with WCS coordinates of a point selected through a paper space viewport.
;; Coords
;; Creates a leader in the paper space which text is WCS coordinates of the selected point
(defun c:Coords (/ vp elst os pt1 pt2 pt)
(vl-load-com)
(or *acdoc*
(setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
)
(if (= (getvar "TILEMODE") 0)
(progn
(vla-put-MSpace *acdoc* :vlax-False)
(and
(setq vp (car (entsel "\nSelect a viewport: ")))
(setq elst (entget vp))
(or (= (cdr (assoc 0 elst)) "VIEWPORT")
(and (member (cdr (assoc 0 elst))
'("CIRCLE" "ELLIPSE" "LWPOLYLINE" "REGION" "SPLINE")
)
(setq vp (cdr (assoc 330 elst)))
(= (cdr (assoc 0 (entget vp))) "VIEWPORT")
)
)
(setq vp (vlax-ename->vla-object vp))
(= (vla-get-ObjectName vp) "AcDbViewport")
(setq os (osmodes))
(while
(and
(setq pt1 (getpoint "\nFirst point of the leader: "))
(setq pt1 (trans pt1 1 0))
(not (vla-put-MSpace *acdoc* :vlax-true))
(not (vla-put-activePViewport *acdoc* vp))
(setq pt (osnap (trans (trans pt1 3 2) 2 1) os))
(setq pt (trans pt 1 0))
(not (vla-put-MSpace *acdoc* :vlax-False))
(setq pt1 (trans pt1 0 1))
(setq pt2 (getpoint pt1 "\nFollowing point: "))
)
(vl-cmdf "_.leader"
"_non"
pt1
"_non"
pt2
""
(strcat
(rtos (car pt))
" "
(rtos (cadr pt))
;" "
;(rtos (caddr pt))
)
""
)
)
(vla-put-MSpace *acdoc* :vlax-False)
)
)
(princ
"\nThis command is only available in layouts."
)
)
(princ)
)
;; osmodes
;; Returns a strin of active osnaps
(defun osmodes (/ os str)
(setq os (getvar 'osmode)
str ""
)
(mapcar
(function
(lambda (m b)
(if (= b (logand b os))
(setq str (strcat str m ","))
)
)
)
'("_end" "_mid" "_cen" "_nod" "_qua" "_int" "_ins" "_nea")
'(1 2 4 8 16 32 64 512)
)
str
)