Search the Community
Showing results for tags 'center text in box'.
Found 1 result
I found this code on the web somewhere and it works great for a single line of text. I would like to be able to select multiple lines of text and have it do the same. To center several lines of text in an existing rectangle. I am hoping someone already has code to do this rather than hoping someone would code it for me. I am clueless on how to do this.. Many times what I encounter is multiple lines of individual text items. So it may be TEXT or it may be MTEXT. Here is the existing code which works great for a single line of text: ; PLACE TEXT AT THE CENTER OF A BOX OR A CIRCLE, ; IRRESPECTIVE OF TEXT'S INS.PT ; By G. Ramesh, NPCC, Abu Dhabi. (defun c:CTT(/ e el p1 p2 mid tb sp ll ur mid1 dis) (Princ "\nCenter Text in Box. ") (setvar "cmdecho" 0) (setq e (car(entsel "\nPick the text: ")) el (entget e)) (initget "Window Circle") (setq opt (getkword "\nTo be enclosed within a Window/Circle <W>: ")) (if (or (not opt) (= opt "WINDOW")) (setq p1 (getpoint "\nFirst corner of the enclosing box: ") p2 (getcorner p1 "\nOther corner: ") mid (polar p1 (angle p1 p2) (/ (distance p1 p2) 2)) ) (setq mid (cdr(assoc 10 (entget(car(entsel "\nSelect a CIRCLE: ")))))) ) (setq tb (textbox el) sp (cdr(assoc 10 el)) ll (mapcar '+ (car tb) sp) ur (mapcar '+ ll (mapcar '- (cadr tb) (car tb))) mid1 (polar ll (angle ll ur) (/ (distance ll ur) 2.0)) dis (mapcar '- mid mid1) ) (command ".move" e "" dis "") (prin1) ) Apologies for the formatting being all wonky, it was like that... Thanks much!