AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Here's a lisp that annotates lines with their decimal distance :

;CODING STARTS HERE
(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))
(command "text" "m" p1 txt_size (angtos aa) (strcat txt "'"))
txt))))

(defun C:an (/ 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)))
)
nil)))

(setvar "cmdecho" 1)
(princ))

;CODING ENDS HERE

Adam Tullis

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website