This is thrown together form parts of other routines.
It worked for me but No guaranties.
Could use more error checking & lots of cleanup.
PS, I like Tim's routine, but I'll post mine anyway.
;; CAB 02/06/06
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;; L e a d e r R o u t i n e
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
(defun c:elevled (/ p1 p2 p3 txtent)
;; error function & Routine Exit
(defun *error* (msg)
(if
(not
(member
msg
'("console break" "Function cancelled" "quit / exit abort" "")
)
)
(princ (strcat "\nError: " msg))
) ; endif
;;reset all variables here
(and tmpline (entdel tmpline))
(and usrorm (setvar "orthomode" usrorm))
(and useros (setvar "osmode" useros))
(and usercmd (setvar "CMDECHO" usercmd))
(setq usrorm nil
useros nil
usercmd nil
tmpline nil)
) ;end error function
(vl-load-com)
(setq usercmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq usrorm (getvar "orthomode"))
(setvar "orthomode" 0)
(if (and (setq p1 (getpoint "\nPick start point of leader."))
(setq useros (getvar "osmode"))
(setvar "osmode" 0)
(setq p2 (getpoint p1 "\nPick next point of leader.")))
(progn
(command ".line" p1 p2 "")
(setq tmpline (entlast))
(setvar "orthomode" 1)
(setq p3 (getpoint p2 "\nPick end of leader."))
(entdel tmpline) ; delete line
(setq tmpline nil)
(setq txtent (Get_Elev (if p3 p3 p2)))
(if txtent ; create leader
(Makeldr p1 p2 p3 (entlast))
)
)
)
(*error* "")
(princ)
)
(princ)
(defun makeldr (p1 p2 p3 txt / coords1 coords2 ldr1 ldr2 space)
(vl-load-com)
(setq txt (vlax-ename->vla-object txt))
(setq coords1 (append p1 p2))
(if p3
(setq coords1 (append coords1 p3))
)
(setq space (vla-objectidtoobject
(vla-get-activedocument
(vlax-get-acad-object)
)
(vla-get-ownerid txt)
)
)
(setq ldr1 (vlax-invoke space "addleader" coords1 txt aclinewitharrow))
(vla-put-verticaltextposition ldr1 0)
(princ)
)
(defun Get_elev (pt / txt cnt elev val)
(or *base* (setq *base* 100.0))
(setq val (getdist (strcat "\nEnter *base* Elevation: <" (rtos *base* 2 2) ">")))
(setq *base* (if val val *base*)
txt (strcat "T.C. = " (rtos *base* 2 2) "\\P")
cnt 1)
(While (setq elev (getdist "\nEnter Offset to *base* Elevation:"))
(setq txt (strcat txt "INV " (itoa cnt) " = " (rtos (- *base* elev) 2 2)"\\P")
cnt (1+ cnt)
)
)
(entmake (list
'(0 . "MTEXT")
'(100 . "AcDbEntity")
'(100 . "AcDbMText")
(cons 10 pt) ; insert point
(cons 7 (getvar "TextStyle")) ; Current Style
(cons 40 (getvar "TextSize")) ; Current height
(cons 41 0) ; 0 Width = no wrap
(cons 71 1) ; 1=Top Left Attachment point
(cons 1 txt) ; Text String
)
)
)
(princ); load quietly