PDA

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)))
)
&#40;if &#40;< &#40;/ pi 2&#41; aa &#40;* pi 1.5&#41;&#41;
&#40;setq p1 &#40;cdr &#40;assoc 11 el&#41;&#41;
aa &#40;rem &#40;+ aa pi&#41;&#40;* pi 2&#41;&#41;&#41;
&#40;setq p1 &#40;cdr &#40;assoc 10 el&#41;&#41;&#41;&#41;

&#40;setq p1 &#40;polar
&#40;polar p1 aa &#40;/ dd 2&#41;&#41;
&#40;if &#40;null side&#41;
&#40;+ aa &#40;/ pi 2&#41;&#41;
&#40;- aa &#40;/ pi 2&#41;&#41;&#41;
txt_size&#41;&#41;
&#40;setq DegLab &#40;vl-string-subst "%%d" "d" txt&#41;&#41;;;NEW LINE TO REPLACE D with %%D
&#40;command "text" "m" p1 txt_size &#40;angtos aa&#41; DegLab&#41; ;;REVISED LINE
txt&#41;&#41;&#41;&#41;


&#40;defun C&#58;annotate &#40;/ en el&#41;
&#40;setvar "cmdecho" 0&#41;
&#40;setq en &#40;car &#40;entsel "\nPick a Line&#58; "&#41;&#41;
el &#40;entget en&#41;&#41;
&#40;if &#40;= &#40;cdr &#40;assoc 0 el&#41;&#41; "LINE"&#41;
&#40;progn
&#40;text_line en
&#40;rtos &#40;distance &#40;cdr &#40;assoc 10 el&#41;&#41;
&#40;cdr &#40;assoc 11 el&#41;&#41;&#41;
2 4&#41; ;;REVISED FOR DECIMAL, 2 PLACES
nil&#41;
&#40;text_line en
&#40;angtos &#40;angle &#40;cdr &#40;assoc 10 el&#41;&#41;
&#40;cdr &#40;assoc 11 el&#41;&#41;&#41;
4 3&#41;
1&#41;
&#41;
&#41;
&#40;setvar "cmdecho" 1&#41;
&#40;princ&#41;
&#41;