dnovember99 Posted May 11, 2018 Share Posted May 11, 2018 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 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 11, 2018 Share Posted May 11, 2018 All you need to do is toggle justify in the properties palette ? Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted May 11, 2018 Author Share Posted May 11, 2018 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 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 11, 2018 Share Posted May 11, 2018 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 Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted May 11, 2018 Author Share Posted May 11, 2018 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 11, 2018 Share Posted May 11, 2018 (edited) Try this: (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 . (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) ) Edited May 11, 2018 by Lee Mac Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 11, 2018 Share Posted May 11, 2018 (edited) Nice Lee .. here's another quick one. (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) Edited May 11, 2018 by ronjonp *added all justification options Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted May 11, 2018 Author Share Posted May 11, 2018 Try this:(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 . (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. ;; 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. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 11, 2018 Share Posted May 11, 2018 Good stuff Ron Quote Link to comment Share on other sites More sharing options...
ronjonp Posted May 11, 2018 Share Posted May 11, 2018 Good stuff Ron Cheers! Quote Link to comment Share on other sites More sharing options...
tombu Posted May 11, 2018 Share Posted May 11, 2018 You could add JT as an alias to JUSTIFYTEXT in Acad.pgp using the ALIASEDIT Express Tool or make a Ctrl+J Shortcut Key for it under Keyboard Shortcuts in the CUI One more option is to add a 'Justify Text' flyout to both 'Mtext Object Menu' and 'Mtext Objects Menu' Under 'Shortcut Menus' in the CUI with commands for each option like: Name TL Macro $M=$(if,$(eq,$(substr,$(getvar,cmdnames),1,4),GRIP),_justifytext;TL;,^C^C_justifytext;TL) and another Justify Text flyout to both 'Text Object Menu' and 'Text Objects Menu' Under 'Shortcut Menus' in the CUI with commands for each option like: Name Left Macro $M=$(if,$(eq,$(substr,$(getvar,cmdnames),1,4),GRIP),_justifytext;TL;,^C^C_justifytext;Left) I can use the shortcut Ctrl+J, enter JT, or right-click selected text and pick 'Justify Text' to select the justification. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 11, 2018 Share Posted May 11, 2018 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. You should find that the justification is set as follows: 7=Top-Left, 8=Top-Center, 9=Top-Right, 4=Middle-Left, 5=Middle-Center, 6=Middle-Right, 1=Bottom-Left etc. This is confirmed in my testing - is this not the case? Quote Link to comment Share on other sites More sharing options...
rlx Posted May 11, 2018 Share Posted May 11, 2018 You should find that the justification is set as follows: 7=Top-Left, 8=Top-Center, 9=Top-Right, 4=Middle-Left, 5=Middle-Center, 6=Middle-Right, 1=Bottom-Left etc. This is confirmed in my testing - is this not the case? Numeric layouts can differ. At my work couple of colleagues are from Belgium and they prefer their own keyboard layout so having to type something on their keybord is well, challenging to say the least. But nice little routine, both from you and ronjonp. Quote Link to comment Share on other sites More sharing options...
dober Posted May 15, 2018 Share Posted May 15, 2018 @ Lee If that were synonymous with text, now it works only with MTexte Würde das auch mit Text gehen, jetzt funktioniert das nur mit MTexte Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 15, 2018 Share Posted May 15, 2018 @ LeeIf that were synonymous with text, now it works only with MTexte The following should work with both - (defun c:mj ( / g i k l s ) (setq k '( (49 ((71 . 7)) ((72 . 0) (73 . 1))) (50 ((71 . ) ((72 . 1) (73 . 1))) (51 ((71 . 9)) ((72 . 2) (73 . 1))) (52 ((71 . 4)) ((72 . 0) (73 . 2))) (53 ((71 . 5)) ((72 . 1) (73 . 2))) (54 ((71 . 6)) ((72 . 2) (73 . 2))) (55 ((71 . 1)) ((72 . 0) (73 . 3))) (56 ((71 . 2)) ((72 . 1) (73 . 3))) (57 ((71 . 3)) ((72 . 2) (73 . 3))) ) ) (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT")))) (progn (repeat (setq i (sslength s)) (setq i (1- i) x (entget (ssname s i)) ) (if (and (= "TEXT" (cdr (assoc 0 x))) (= 0 (cdr (assoc 72 x)) (cdr (assoc 73 x)))) (entmod (setq x (subst (cons 11 (cdr (assoc 10 x))) (assoc 11 x) x))); (subst '(73 . 1) '(73 . 0) x))) ) (setq l (cons x l)) ) (princ "\nAlter the alignment using the numberpad <done>: ") (while (and (= 2 (car (setq g (grread nil 2)))) (< 48 (cadr g) 58)) (setq g (cdr (assoc (cadr g) k))) (foreach x l (foreach y (if (= "MTEXT" (cdr (assoc 0 x))) (car g) (cadr g)) (setq x (subst y (assoc (car y) x) x)) ) (entmod x) ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
dober Posted May 15, 2018 Share Posted May 15, 2018 Thank you perfect LEE As always tooles Lisp Danke perfekt LEE Wie immer tooles Lisp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.