Jump to content

is it possible to align single line text?


Recommended Posts

Does anyone know or is it possible to align sinlge line text, without using multi-text.

 

I want to keep them separate but align them underneath each other without trying to eyeball it?

Link to comment
Share on other sites

Once you have entered one line of text, which is left justified. when you start the next instance of text, and it wants a starting point, just press enter, and the new text will be below the previous text and justified (aligned) to it. :D

Link to comment
Share on other sites

An Mtext can be exploded to Texts (one Text for each line from the Mtext). Afret exploding, Texts will keep their positions on the screen.

Does this help you?

Link to comment
Share on other sites

you can draw a vertical line and move each text from it's ins (insertion point) perp to that line...or, if you know the x coordinate value select all the text and type in the x value in the properties panel--assuming of course that all the text has the same justification...

 

ortho is good too as well as polar as you copy down...once you have two text lines then you can also use the insertion point of the text as a refence to copy down to the next insertion point and so on...

Link to comment
Share on other sites

Does anyone know or is it possible to align sinlge line text, without using multi-text.

 

I want to keep them separate but align them underneath each other without trying to eyeball it?

 

Assuming you are wanting to add more text directly aligned with exiting text. I would use Otrack and Osnaps. Set the Insertion Osnap on, turn on Otrack, start the text command, hoover over the existing text to acquire the insertion point (don't click, just hoover) then move your cursor up or down and notice the guide line now there, pick a Y value that is 270 degrees or 90 degrees from the text.

Link to comment
Share on other sites

Another wonderful AutoCAD cat-skinning session :D

 

I usually use MTEXT, but if I'm working in a drawing in a drawing with unaligned single line text I usually shoot a ray vertically, select all the text and use the grip point to move it to the ray. This also works will if there are some pesky multileaders sitting out of alignment (one of my ultimate pet peeves, its so easy to align things with OTRACK...do it :x ).

Link to comment
Share on other sites

Assuming the text has the same justification, rotation, etc.

 

If you want to align existing text to a vertical line so the insertion points of each text entity starts on the vertical line: (in no particular order)

1. Draw a line, set onsnap to insertion and perp, start the move command and move the text one at a time.

2. ID a point to obtain the X value you want all text to start at, pick the text, go into properties and set the X value to the one you obtained.

3. Use a lisp routine, like the one attached.

4. Set otrack on, set onsnap to insertion, or endpoint depending on whether you are using text or a line to align to, use move with otrack to move to new location.

 

If adding new text below existing:

1. use mtext and either leave as mtext or explode.

2. copy some text vertically and edit

3. using otrack and osnap set to insertion, start text and obtain otrack, ....

4. draw a vertical line, snap to that for each text, erase line.

5. if the last piece of text is in the location that you want the next piece of text to align to, simply start the text command, hit enter and the text will be directly below the other piece.

6. start mtext command, osnap to text insertion, hit space a few times, explode.

 

;|

This lisp routine allows you to relocate scattered text to a

new vertical guideline. The routine first asks you for the guideline,

then prompts you to select the TEXT to be moved.

|;

(defun C:MVT ( / TXT TXTLTH MODTXT X OLDX NEWX NEWTXT XGUIDE)

(setq XGUIDE (cadr (assoc 10 (entget (car (entsel "Select vertical guideline: "

))))))

(princ "\nSelect text for relocation: ")

(setq TXT (ssget))

(setq TXTLTH (sslength TXT))

(setq MODTXT 0)

(repeat TXTLTH

(SETQ X (ENTGET (ssname TXT MODTXT)))

(SETQ MODTXT (1+ MODTXT))

(SETQ OLDX (assoc 10 X))

(SETQ NEWX (list (car OLDX) XGUIDE (caddr OLDX) (cadddr OLDX)))

(SETQ NEWTXT (subst NEWX OLDX X))

(entmod NEWTXT)

)

(princ)

)

(princ

" Start command with MVT.")

(princ)

Link to comment
Share on other sites

yea, A lisp is a good way to accomplish this, here's one CAB wrote that is simple & works well.

 

;;  CAB 11.12.08  Version 1.1
;;
;;  Align a group of text or mtext objects along there X or Y axis
;;  User picks Master text & then text to align under it
;;  Does not change the text alignment or justification or combine text
;;  Uses the justification of the Master text to set alignment
;;  This routine simply moves & rotates the text
;;  Will allow Master text on any angle
;;
;;  -----   N O T E S  ------
;;  only supports vertical alignment at this time, will add Horizontal
;;  you must select text in order top to bottom, need to allow sorting
;;    on the x or y axis, see note on line 47
;;  No support for UCS at this time
;;
(defun c:at() (c:TextAlign)) ; shortcut
(defun c:TextAlign (/ t1 xy ent elist ss lst cor dir bang gap npt ename clst i obj
                   atpm atp$ ppt
                   atp_decode_mText atp_decode_Text
                   )
 (vl-load-com)
 (defun atp_decode_mText (code)
   (cond
     ((vl-position code '(1 4 7)) "Left")
     ((vl-position code '(2 5 ) "Center")
     ((vl-position code '(3 6 9)) "Right")
   )
 )
 (defun atp_decode_Text (code)
   ;;  3 - acAlignmentAligned
   ;;  5 - acAlignmentFit 
   (cond
     ((vl-position code '(0 6 9 12)) "Left")
     ((vl-position code '(1 4 7 10 13 3 5)) "Center")
     ((vl-position code '(2 8 11 14)) "Right")
   )
 )

 ;;============================
 ;;      S T A R T   H E R E   
 ;;============================
 (setvar "errno" 0)
 (setq xy "X")
 (while
   (progn
     (initget "V H")
     (setq
       t1 (entsel
            "\nSelect master text to align Verticaly or <\"H\"> to align Horrizontally:  "
          ))
       (cond
         ((null t1) (setq xy "X"))
         ((= t1 "H") (setq xy "Y"))
         ((listp t1)
          (setq ent (car t1)
                elist (entget ent))
          (if (not (member (cdr (assoc 0 elist)) '("TEXT" "MTEXT")))
            (princ "\nError - must be a text object.")
          )
         )
         (t (princ "\nMissed, Try again."))
       )
     )
 ) ; end while
 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ;;  Note that ssget will order the selections within the selection set only
 ;;  when the picks are one at at time.  Therefore any sorting based on X,Y
 ;;  coordinates might want to give priority to those items selected first
 ;;  If the (caar value is 1 then it is a PICK else window or other sel method
 ;;
 ;;  At this time only the selection set order is being used: version 1.0
 (prompt "\nSelect Text to align with Master Text.")
 (if (setq ss (ssget '((0 . "TEXT,MTEXT"))))
   (progn
     (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
     (vla-StartUndoMark (vla-get-activedocument (vlax-get-acad-object)))
     (setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
     (setq lst (vl-remove ent lst)) ; remove master if it was selected again
     ;;  got a master text object
     (cond
       ((= (cdr (assoc 0 elist)) "TEXT") 
        (setq cor (get_box_dtext ent)) ; get the corners '(ll lr ur ul)
        (setq atpm (atp_decode_Text (vla-get-Alignment (vlax-ename->vla-object ent))))
        )
       (t ; mText
        (setq cor (get_box_mtext ent)) ; get the corners '(ll lr ur ul)
        (setq atpm (atp_decode_mText (vla-get-AttachmentPoint (vlax-ename->vla-object ent))))
        )
     )

     (setq dir (angle (last cor) (car cor)) ; offset direction
           bang (angle (car cor)(cadr cor)) ; Base angle
           gap  (* (cdr(assoc 40 elist)) 0.6666) ; text height of master text
     )
     ;;  correct for near zero angle
     (if (equal dir (* 2 pi) 0.0001) (setq dir 0.0))
     (if (equal bang (* 2 pi) 0.0001) (setq bang 0.0))
     (cond ; get next point
       ((= atpm "Left")   (setq npt (polar (car cor) dir gap)))
       ((= atpm "Center") (setq npt (polar (polar (car cor) bang
                                                  (/ (distance (car cor)(cadr cor)) 2.)) dir gap)))
       ((= atpm "Right")  (setq npt (polar (cadr cor) dir gap)))
     )
     (setq i -1)
     (while (setq ename (ssname ss (setq i (1+ i))))
       (setq obj (vlax-ename->vla-object ename))
       (cond
         ((= (cdr (assoc 0 (entget ename))) "TEXT")
          (setq clst (get_box_dtext ename)) ; get the corners '(ll lr ur ul)
          ;(setq atp$ (atp_decode_Text (vla-get-Alignment obj)))
          )
         (t ; mText
          (setq clst (get_box_mtext ename)) ; get the corners '(ll lr ur ul)
          ;(setq atp$ (atp_decode_mText (vla-get-AttachmentPoint obj)))
          )
       )
       (cond ; get base point for MOVE [TL TC TR]
         ((= atpm "Left")   (setq ppt (vlax-3d-point(last clst))))
         ((= atpm "Center")
          (setq ppt (vlax-3d-point(polar (last clst) bang (/ (distance (car clst)(cadr clst)) 2.)))))
         ((= atpm "Right")  (setq ppt (vlax-3d-point(caddr clst))))
       )

       ;(command "rectang" "non" (car clst) "non" (caddr clst)) ; debug
       ;;  Move the text into place & rotate if needed
       (vla-move obj ppt (vlax-3d-point npt)) ; WCS
       (if (not(equal bang (vla-get-rotation obj) 0.0001))
         (vla-rotate obj (vlax-3d-point npt) (- bang (vla-get-rotation obj)))
       )
       ;;  advance the point for top left of next text ent
       (setq npt (polar npt dir (+ gap (distance (car clst)(last clst)))))
       ;(setq clst (get_box_dtext ename)) ; debug
       ;(command "rectang" "non" (car clst) "non" (caddr clst)) ; debug
     )
     (vla-EndUndoMark (vla-get-ActiveDocument (vlax-get-acad-object)))
   ) ; progn
 ) ; endif
 ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 (princ)
)  

Link to comment
Share on other sites

You select the text first, then specify the point of alignment

 

(defun c:txa ()
 (setq ss1 (ssget '((-4 . "<OR") 
             (0 . "TEXT")
             (0 . "MTEXT")
             (0 . "RTEXT")
            (-4 . "OR>")
           )))
 (setq xpoint (trans (getpoint "\nSpecify new x-coordinate for all selected text origin: ") 1 0))
 (setq ent-index 0)
 (setq update-index 0)
 (repeat (sslength ss1)
   (setq entname (ssname ss1 ent-index))
   (setq entlist (entget entname))
   (setq entlist (subst (cons 10 (list (car xpoint) (cadr (cdr (assoc 10 entlist))))) (assoc 10 entlist) entlist))
   (entmod entlist)
   (entupd entname)
   (setq update-index (1+ update-index))
   (setq ent-index (1+ ent-index))
 ); repeat  
 (princ (strcat "\nUpdated " (itoa update-index) " text entity(ies).")); sample closing msg
 (princ)  
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...