Display full version of the post: align text

Kajito
11.11.2008, 16:32
Hi guys,

I need help with the following. I guess it should be pretty simple but I cannot get this sorted myself.
What I'd like to have is a tool (command, button, lisp) that will align text to a line. Manually I would do it the way that I would select the text, go to properties and change the x or y value for all of them so that all the labels are aligned to x or y axis.
I've been thinking about an lisp that would work the way that I will select all the text (labels), enter, than pick the label or line from which the other text would adjust the x or y value.
Can anybody help?
Thanks

Kajito
13.11.2008, 13:58
ok,
actually I got it. I tried to googe it again and I've found the lisp I was looking for.
Here is the lisp just in case somebody would like to use it as well. My thanks goes to Ramesh Gopal on cadalyst forum.

;;; CADALYST 03/08 www.cadalyst.com/code
;;; Tip 2275: TAL.lsp     Align Text (c) 2008 Ramesh Gopal

; Align a group of TEXT in line with a reference TEXT, horizontally or vertically.
; BY G. Ramesh, NPCC, Abu Dhabi, UAE

(defun C:TALIGN(/ ang newpt p1 p2 p3 p4 chk ss sl i ref opt n rlist elist el1 ep)
(setq ss (ssget) sl (sslength ss) i 0
       ref (car(entsel "\nPick the reference TEXT: "))
       chk (reverse(cdr(reverse(assoc 11 (entget ref)))))
       ang (cdr(assoc 50 (entget ref)))
)
(initget "Ver Hor")
(setq opt (getkword "\nAlign TEXT Vertically or Horizontally <Ver>? "))
(if (not opt) (setq opt "Ver"))
(if (equal chk '(11 0.0 0.0)) (setq n 10) (setq n 11))
(setq rlist (assoc n (setq elist (entget ref))))
(repeat sl
(setq el1 (entget(ssname ss i)) ep (assoc n el1))
(if (= opt "Hor")
   (progn
    (setq p1 (cdr rlist) p2 (polar p1 ang 5.0)
      p3 (cdr ep) p4 (polar p3 (+ ang (/ pi 2)) 5.0)
      newpt (inters p1 p2 p3 p4 nil)
    )
    (entmod (subst (list (car ep) (car newpt) (cadr newpt) (last ep)) ep el1))
   )
   (progn
    (setq p1 (cdr rlist) p2 (polar p1 (- ang (/ pi 2)) 5.0)
      p3 (cdr ep) p4 (polar p3 ang 5.0)
      newpt (inters p1 p2 p3 p4 nil)
    )
    (entmod (subst (list (car ep) (car newpt) (cadr newpt) (last ep)) ep el1))
   )
)
(setq i (1+ i))
)(prin1)
)