;;; TA.LSP Version 3.0 - 01 MAR 1998
;;;
;;; Copyright 1998 by R.K. McSwain
;;;
;;; Permission to use, copy, modify, and distribute this software
;;; for any purpose and without fee is hereby granted, provided
;;; that the above copyright notice appears in all copies and
;;; that both that copyright notice and the limited warranty and
;;; restricted rights notice below appear in all supporting
;;; documentation.
;;;
;;; R.K. McSwain provides this program "AS IS" and with all faults.
;;; R.K. McSwain specifically disclaims any implied warranty of
;;; merchantability or fitness for a particular use. autodesk, inc.
;;; does not warrant that the operation of the program will be
;;; uninterrupted or error free.
;;; This program will match text angle to a line angle selected
;;;--------------------------------------------------------------------
(defun c:textalign ( / ang1 ang2 bob enttyp enttyp2 getit l1 nang oang oangprt p1 p2 sl st time time2 tx1 wait wait2 why x1 x2 )
(setvar "cmdecho" 1)
;finds the angle of the line
(setq wait "T")
(while wait
(setq time "T")
(while time
(setq sl (entsel "\n Pick Angle To Match:"))
(if (/= sl nil)(setq time nil))
)
(setq l1 (entget (car sl)))
(setq enttyp (cdr (assoc 0 l1)))
(if (= enttyp "LINE")(setq wait nil))
)
(setq p1 (cdr (assoc 10 l1)))
(setq x1 (car p1))
(setq p2 (cdr (assoc 11 l1)))
(setq x2 (car p2))
(setq why (angle p1 p2))
(if (>= why 0)
(setq ang1 why)
)
(if (> why 1.5708);same as 90°
(setq ang1 (+ 3.14159 why));add 180°
)
(if (>= why 4.71413);same as 270.1°
(setq ang1 why)
)
;finds angle of txt
(setq wait2 "T")
(while wait2
(setq time2 "T")
(while time2
(setq st (entsel "\n Pick Text To Change:"))
(if (/= st nil)(setq time2 nil))
)
(setq tx1 (entget (car st)))
(setq enttyp2 (cdr (assoc 0 tx1)))
(if (= enttyp2 "TEXT")(setq wait2 nil))
)
(setq ang2 (cdr (assoc 50 tx1)))
(setq oang (cons 50 ang2))
(setq nang (cons 50 ang1))
(setq tx1 (subst nang oang tx1))
(entmod tx1)
(terpri)
(setq bob "T")
(while bob
(initget 6 "M m")
(setq getit (getkword "\n Press M to rotate 180° or <ENTER> to quit "))
(if (or (= getit "m") (= getit "M"))
(progn
(setq oang (assoc 50 tx1))
(setq oangprt (cdr oang))
(setq nang (cons 50 (+ 3.14159 oangprt)))
(setq tx1 (subst nang oang tx1))
(entmod tx1)
)
(setq bob nil)
)
)
(setvar "cmdecho" 0)
(princ)
)