Well its close to Christmas time, so I thought I would share my #1 favorite lisp code with everyone who's read my BLOG this year. So what is this code? The code is called TLEAD. TLEAD stands for Text leader. The difference between this code and may AutoCAD commands like LEADER and QLEADER is this one actually allows you to control the way the leader is placed.
When you issue the TLEAD command you are prompted to select a string of text. Here you can select the left or right side of the string of text. You then select the start point for the leader, and you'll now get a rubber band effect with a horizontal tracking. You then can select the point you want to place the landing for the leader, and thats it. This command I probably use hundreds of times a day. By far the most popular command in our office.
I hope everyone enjoys this little routine, and has a wonderful holiday.
You can download the file here: Download TLEAD.LSP
(/ tobj tlist dtlist dtinsp dtenttb p1 p2 dthalfwidth+gap)
(setvar "cmdecho" 0)
(setq tobj (entsel "\nSelect Top or Bottom Line of Text: "))
(setq tlist (entget (car tobj)))
(if (= (cdr (assoc 0 tlist)) "TEXT")
(setq dtenttb (textbox (entget (car tobj))))
(setq dtlist (entget (car tobj)))
(if (= (cdr (assoc 0 tlist)) "MTEXT")
(command "explode" tobj)
(setq mtline (ssget (cadr tobj))) ;warning! This uses the cursor's position, not an actual object point!
(setq dtlist (entget (ssname mtline 0)))
(setq dtenttb (textbox (entget (ssname mtline 0))))
(setq dtinspt (cdr (assoc 10 dtlist)))
(setq p1 (list (/ (+ (caadr dtenttb) (caar dtenttb)) 2.0)
(/ (+ (cadar dtenttb) (cadadr dtenttb)) 2.0)
(cadddr (assoc 10 dtlist))
(setq inspt (list (+ (car dtinspt) (car p1))
(+ (cadr dtinspt) (cadr p1))
(+ (caddr dtinspt) (caddr p1))
(+ (/ (- (caadr dtenttb) (caar dtenttb)) 2.0)
(* 0.03625 (getvar "dimscale"))
(prompt "\nSelect Leader Start and Bend Points: ")
(polar inspt (angle inspt (getvar "lastpoint")) dthalfwidth+gap)