+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 16
  1. #1
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default aligning text within text editor.

    Registered forum members do not see this ad.

    so i have been looking for some time now to try and find something that will be able to help me with this. i want to be and to have the text within Mtext to be aligned right, center or left. the only way that i can see to do that right now is to double click, highlight the text and then selection it from the ribbon.

    i have tried to use textalign command and that just doesnt seem to move the text to the right, center or left.

    anyone know of a lisp out there that you would be able to just choose left, right or center and then click the text that you want to change?

    thank you all

  2. #2
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    835

    Default

    All you need to do is toggle justify in the properties palette ?

  3. #3
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default

    yes, i just am the type that doesnt like using the palette. just thought i would see if there is something out there that could make things a little faster

  4. #4
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    835

    Default

    Quote Originally Posted by dnovember99 View Post
    yes, i just am the type that doesnt like using the palette. just thought i would see if there is something out there that could make things a little faster
    Fair enough .. I'll hammer out some code in a bit if someone else does not jump in

  5. #5
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default

    oh awesome! the other thing that i am not a fan of with using that palette is if you have Mtext and dont have the box out to a certain size when you do hit justify from right to left it moves the text. so that is another extra step. not sure if that can be considered also or not. if not all good. just thought that i would throw it out there.

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,533

    Default

    Try this:
    Code:
    (defun c:mj ( / g i l s )
        (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
            (progn
                (repeat (setq i (sslength s))
                    (setq l (cons (entget (ssname s (setq i (1- i)))) l))
                )
                (princ "\nAlter the alignment using the numberpad <done>: ")
                (while (and (= 2 (car (setq g (grread nil 2)))) (< 48 (cadr g) 58))
                    (setq g (cons 71 (cdr (assoc (cadr g) '((49 . 7)(50 . 8)(51 . 9)(52 . 4)(53 . 5)(54 . 6)(55 . 1)(56 . 2)(57 . 3))))))
                    (foreach x l (entmod (subst g (assoc 71 x) x)))
                )
            )
        )
        (princ)
    )
    mtextjustification.gif
    Last edited by Lee Mac; 11th May 2018 at 10:17 pm.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  7. #7
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    835

    Default

    Nice Lee .. here's another quick one.
    Code:
    (defun c:just (/ j k s)
      (setq j '("TL" "TC" "TR" "ML" "MC" "MR" "BL" "BC" "BR"))
      (initget 0 (apply 'strcat (mapcar '(lambda (x) (strcat x " ")) j)))
      (cond
        ((and (or (setq
    		k (getkword
    		    (strcat "\n[" (apply 'strcat (mapcar '(lambda (x) (strcat x "/")) j)) "]: <TL>")
    		  )
    	      )
    	      (setq k "TL")
    	  )
    	  (setq s (ssget ":L" '((0 . "mtext"))))
         )
         (foreach e	(vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
           (vla-put-attachmentpoint (vlax-ename->vla-object e) (1+ (vl-position k j)))
         )
        )
      )
      (princ)
    )
    (vl-load-com)
    Last edited by ronjonp; 11th May 2018 at 06:54 pm. Reason: *added all justification options

  8. #8
    Full Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2016
    Join Date
    Nov 2017
    Posts
    72

    Default

    Quote Originally Posted by Lee Mac View Post
    Try this:
    Code:
    (defun c:mj ( / g i l s )
        (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
            (progn
                (repeat (setq i (sslength s))
                    (setq l (cons (entget (ssname s (setq i (1- i)))) l))
                )
                (princ "\nAlter the alignment using the numberpad <done>: ")
                (while (and (= 2 (car (setq g (grread nil 2)))) (< 48 (cadr g) 58))
                    (setq g (cons 71 (cdr (assoc (cadr g) '((49 . 7)(50 . 8)(51 . 9)(52 . 4)(53 . 5)(54 . 6)(55 . 1)(56 . 2)(57 . 3))))))
                    (foreach x l (entmod (subst g (assoc 71 x) x)))
                )
            )
        )
        (princ)
    )
    Mr. Mac, thank you for this. i was playing around with it and i noticed that on the key pad (9)is bottom (6) center and (3) top and then the other side (7) bottom (4) center and (1) top.

    i think that is to where you want to have the leader showing at. am i thinking correctly? i was thinking more along the lines of when you double click on the text, highlight the text and while in text editor just above "paragraph" you can select the "justify" right, left, center, etc.

    i was talking with someone and they told me that just using a macro could work. here is what i was given.

    Code:
    ;; Justification Macros
    
    
    (defun _justifyIt (justify title / ss)
      (princ (strcat "\nSelect *Text to " title " justify: "))
      (if (setq ss (ssget "_:L" '((0 . "ATTDEF,MTEXT,TEXT"))))
        (command "_.justifytext" ss "" justify)
      )
      (princ)
    )
    
    (defun c:JL (/) (_justifyIt "_L" "Left"))
    (defun c:JR (/) (_justifyIt "_R" "Right"))
    i am noticing that this doesnt work on all mtext. it depends on the justification point it has. and/or it will only work when the text is looking like this. i sure hope that i am making sense with this.

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,533

    Default

    Good stuff Ron
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  10. #10
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    835

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Lee Mac View Post
    Good stuff Ron
    Cheers!

Similar Threads

  1. Text hard to read in the Civil 3D text component editor?
    By CAD Panacea in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 1st Jun 2015, 02:20 pm
  2. Text hard to read in the Civil 3D text component editor?
    By CAD Panacea in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 6th Feb 2013, 03:20 pm
  3. Aligning text around a circle/arc
    By Matho in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 9
    Last Post: 7th May 2009, 06:03 pm
  4. arc with text aligning???
    By avieira in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 30th Apr 2009, 02:23 pm
  5. Underlining text in the Multi text editor.
    By cad07 in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 25th Feb 2007, 11:38 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