View Full Version : Annotate lisp routine.
Chris
9th Nov 2005, 06:47 pm
Thanks you CarlB, your suggestion worked. Maybe you could take a shot at other modifications I would like make to the (annotate.lsp) code. First of all the distances listed are carried out 4 digits pass the decimal and I only need 2 decimal places. The second mod might be a little tougher. When the bearing is annotated the degree symbol is shown as d. Example 25d20'30". As you know to get the actual degree symbol to show in a line of text with autocad you use %%d, so I was wondering if their is a way to get the lisp routine to take care of this or will I just have to edit after using the routine. :?
CarlB
9th Nov 2005, 07:15 pm
One change is easy, the other not.
To get 2 decimal places, change the same line you changed before, but instead of
2 4)
use
2 2)
which tells the 'rtos' function to use 2 decimal places. I'll think some more about the 'd' to %%d' but I don't think there will be any easy fix.
[/code]
CarlB
12th Nov 2005, 01:25 am
Chris,
here's the updated routine to annotate lines. It was actually a simple change to get the degree sign, just changed the "d" to "%%d" prior to annotating.
(defun text_line (en txt side / txt_size el aa dd aa2 p1)
(if (null txt_size)(setq txt_size (getvar "textsize")))
(if (and (= (type txt) 'str)
(= (type en) 'ename))
(if (= "LINE"
(cdr (assoc 0
(setq el (entget en)))))
(progn
(setq aa (angle (cdr (assoc 10 el))
(cdr (assoc 11 el)))
dd (distance (cdr (assoc 10 el))
(cdr (assoc 11 el)))
)
(if (< (/ pi 2) aa (* pi 1.5))
(setq p1 (cdr (assoc 11 el))
aa (rem (+ aa pi)(* pi 2)))
(setq p1 (cdr (assoc 10 el))))
(setq p1 (polar
(polar p1 aa (/ dd 2))
(if (null side)
(+ aa (/ pi 2))
(- aa (/ pi 2)))
txt_size))
(setq DegLab (vl-string-subst "%%d" "d" txt));;NEW LINE TO REPLACE D with %%D
(command "text" "m" p1 txt_size (angtos aa) DegLab) ;;REVISED LINE
txt))))
(defun C:annotate (/ en el)
(setvar "cmdecho" 0)
(setq en (car (entsel "\nPick a Line: "))
el (entget en))
(if (= (cdr (assoc 0 el)) "LINE")
(progn
(text_line en
(rtos (distance (cdr (assoc 10 el))
(cdr (assoc 11 el)))
2 4) ;;REVISED FOR DECIMAL, 2 PLACES
nil)
(text_line en
(angtos (angle (cdr (assoc 10 el))
(cdr (assoc 11 el)))
4 3)
1)
)
)
(setvar "cmdecho" 1)
(princ)
)
Powered by vBulletin™ Version 4.1.2 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.