+ Reply to Thread
Results 1 to 8 of 8

Thread: Text alignment

  1. #1
    Full Member
    Using
    AutoCAD 2009
    Join Date
    Apr 2009
    Posts
    82

    Default Text alignment

    Registered forum members do not see this ad.

    Hi Good day to all, is there any body have a route that will arrange and aligned the text/mtext/attribute on any place where i want to pick on sides or middle (as shown on image)

    By selecting all the text i need to align it on the left or middle or right side so that we will not be able to eye ball it by text alignment. please

    Thanks to all
    Attached Images

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,741

    Default

    This should do MTEXT and TEXT:

    Code:
    (defun c:talign  (/ ss pt tmp elst)
      (vl-load-com)
      (or tal:def (setq tal:def "Left"))
      (if (and (setq ss (ssget '((0 . "*TEXT"))))
               (setq pt (getpoint "\nSelect Alignment Point: ")))
        (progn
          (initget "Left Middle Right")
          (setq tmp (getkword (strcat "\nAlignment? [L/M/R] <" tal:def ">: ")))
          (or (not tmp) (setq tal:def tmp))
          (foreach elst  (mapcar 'entget
                           (vl-remove-if 'listp
                             (mapcar 'cadr (ssnamex ss))))
            (cond ((eq "TEXT" (cdr (assoc 0 elst)))
                   (setq elst (mod 10 (list (car pt)
                                            (caddr (assoc 10 elst))
                                            (cadddr (assoc 10 elst))) elst))
                   (mod 72 (cond ((eq tal:def "Left") 0)
                                 ((eq tal:def "Middle") 1)
                                 ((eq tal:def "Right") 2))
                        (mod 11 (cdr (assoc 10 elst)) elst)))
                  ((eq "MTEXT" (cdr (assoc 0 elst)))
                   (setq elst (mod 10 (list (car pt)
                                            (caddr (assoc 10 elst))
                                            (cadddr (assoc 10 elst))) elst))
                   (mod 71 (cond ((eq tal:def "Left") 1)
                                 ((eq tal:def "Middle") 2)
                                 ((eq tal:def "Right") 3)) elst)))))
        (princ "\n<!> No Text Selected <!>"))
      (princ))
    
    (defun mod (code val elst)
      (entmod
        (subst
          (cons code val)
            (assoc code elst) elst)))
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  3. #3
    Full Member
    Using
    AutoCAD 2009
    Join Date
    Apr 2009
    Posts
    82

    Default

    Thank Lee, function is great only i cannot used on UCS rotated plan, its jump aways the text, can be fix it, Thanks again

  4. #4
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,741

    Default

    Give this a shot, should work with UCS (hopefully!):

    Code:
    (defun c:talign  (/ ss pt tmp elst)
      (vl-load-com)
      (or tal:def (setq tal:def "Left"))
      (if (and (setq ss (ssget '((0 . "*TEXT"))))
               (setq pt (getpoint "\nSelect Alignment Point: ")))
        (progn
          (setq pt (trans pt 1 0))
          (initget "Left Middle Right")
          (setq tmp (getkword (strcat "\nAlignment? [L/M/R] <" tal:def ">: ")))
          (or (not tmp) (setq tal:def tmp))
          (foreach elst  (mapcar 'entget
                           (vl-remove-if 'listp
                             (mapcar 'cadr (ssnamex ss))))
            (cond ((eq "TEXT" (cdr (assoc 0 elst)))
                   (setq elst (mod 10 (list (car pt)
                                            (caddr (assoc 10 elst))
                                            (cadddr (assoc 10 elst))) elst))
                   (mod 72 (cond ((eq tal:def "Left") 0)
                                 ((eq tal:def "Middle") 1)
                                 ((eq tal:def "Right") 2))
                        (mod 11 (cdr (assoc 10 elst)) elst)))
                  ((eq "MTEXT" (cdr (assoc 0 elst)))
                   (setq elst (mod 10 (list (car pt)
                                            (caddr (assoc 10 elst))
                                            (cadddr (assoc 10 elst))) elst))
                   (mod 71 (cond ((eq tal:def "Left") 1)
                                 ((eq tal:def "Middle") 2)
                                 ((eq tal:def "Right") 3)) elst)))))
        (princ "\n<!> No Text Selected <!>"))
      (princ))
    
    (defun mod (code val elst)
      (entmod
        (subst
          (cons code val)
            (assoc code elst) elst)))
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  5. #5
    Full Member
    Using
    AutoCAD 2009
    Join Date
    Apr 2009
    Posts
    82

    Default

    Hi Lee little bit more, the text is not now thrown around only it will not align vertical its just aligning according to Y axis inclined to UCS, see image thanks for your hard work on it Lee,
    Attached Images

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,741

    Default

    Are you sure you are trying the new version? - it works fine for me

    Try closing and re-opening your drawing, and reload the routine and test it again.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  7. #7
    Full Member
    Using
    AutoCAD 2009
    Join Date
    Apr 2009
    Posts
    82

    Default

    Yes its ok LEE, i have an idea how i will us with out using the UCS, i will set to work the text on layout tabs not in the model tabs i will used only the model tabs for working drawings (plans and layouts),

    If the TEXT are completed on the layout tabs, i will use the "talign.Lsp" to align the text and then command "CHSPACE" and select all text and leaders and presto!! the text are transfer to model that not affects the text alingment..

    Thanks LEE for the Lisp..

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,741

    Default

    Registered forum members do not see this ad.

    No probs dude
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. text alignment
    By kris1970 in forum AutoCAD General
    Replies: 2
    Last Post: 12th May 2009, 04:07 pm
  2. Text alignment in annotations
    By Lala in forum AutoCAD General
    Replies: 5
    Last Post: 19th Mar 2009, 05:09 pm
  3. dimension text alignment
    By cadmench in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 21st Nov 2007, 08:13 pm
  4. Problem with text alignment
    By pera451 in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 2nd May 2006, 11:22 am
  5. Dimension text alignment
    By Kate M in forum AutoCAD General
    Replies: 4
    Last Post: 25th Sep 2003, 07:08 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts