PDA

View Full Version : Changing a Lisp



smorales02
23rd Jul 2008, 06:35 pm
I found the following lisp routine that rotates text based on the rotation of a line. My question is, what inside this lisp is making it to where it has to be a Line and not a Pline....I use Plines all the time cause they just make it easier when editing than regular Lines, so I would like to have this routine be able to use a PLine....

Heres the code, thanks lpseifert:



(defun C:TR ()
(setvar "CMDECHO" 0)
(prompt "\nSelect Line: ")
(setq LINE (ssget))
(setq INDEX 0)
(setq ENAME (ssname LINE INDEX))
(setq ELIST (entget ENAME))
(setq PT1 (cdr (assoc 10 ELIST)))
(setq VALUE11 (car PT1))
(setq VALUE12 (cadr PT1))
(setq VALUE13 (caddr PT1))
(setq PT2 (cdr (assoc 11 ELIST)))
(setq VALUE21 (car PT2))
(setq VALUE22 (cadr PT2))
(setq VALUE23 (caddr PT2))
(setq LANGLE (angle PT1 PT2))
(setq P12 (/ pi 2.0))
(setq P32 (* pi 1.5))
(setq P2 (* pi 2.))
(if (and (>= LANGLE 0.0) (<= LANGLE P12))
(setq NARCTAN LANGLE))
(if (and (>= LANGLE P32) (<= LANGLE P2))
(setq NARCTAN LANGLE))
(if (and (>= LANGLE P12) (<= LANGLE pi))
(setq NARCTAN (+ LANGLE pi)))
(if (and (>= LANGLE pi) (<= LANGLE P32))
(setq NARCTAN (- LANGLE pi)))
(prompt "\nSelect Text: ")
(setq TEXTL (entget (car (entsel))))
(setq OTEXT (assoc 50 TEXTL))
(setq NTEXT (cons 50 NARCTAN))
(setq TEXTL (subst NTEXT OTEXT TEXTL))
(entmod TEXTL))

smorales02
23rd Jul 2008, 06:50 pm
edited with code

ASMI
23rd Jul 2008, 06:56 pm
Look for CAB's code: http://www.cadtutor.net/forum/showthread.php?t=11844