marmo Posted October 16, 2018 Posted October 16, 2018 Hallo, I need to change the justification of various mline, that i have in an old drawing, withou changing the position of the mline, like the command TJUST for text. There is a lisp for that? Thank you! Quote
marmo Posted October 16, 2018 Author Posted October 16, 2018 Hi dlanorh, I'm referring to a mline (multi-line), I'm not speaking about a mtext (multi line text). :) Quote
dlanorh Posted October 16, 2018 Posted October 16, 2018 (edited) 3 hours ago, marmo said: Hi dlanorh, I'm referring to a mline (multi-line), I'm not speaking about a mtext (multi line text). Just checking. Try this. It works on a single object at a time but could be adapted. (vl-load-com) (defun c:mlj ( / *error* c_doc ms ml_obj o_lyr objs a_lst e_lst) (defun *error* ( msg ) (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc)) (if (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*EXIT*")) (princ (strcat "\nOops an Error : " msg " occurred."))) (princ) );_end_*error*_defun (setq dynp (getvar 'dynprompt) dynm (getvar 'dynmode) ) (setvar 'dynprompt 1) (setvar 'dynmode 3) (setq c_doc (vla-get-activedocument (vlax-get-acad-object)) j_lst '((0 . "Top") (1 . "Middle") (2 . "Bottom")) jp_lst '("Top" "Middle" "Bottom") );end_setq (while (not ml_obj) (setq ent (car (entsel "\nSelect Multiline Object : "))) (if (= (cdr (assoc 0 (entget ent))) "MLINE") (setq ml_obj (vlax-ename->vla-object ent)) );end_if );end_while (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc)) (vla-startundomark c_doc) (setq ml_just (vlax-get-property ml_obj 'justification)) (initget 1 (vl-string-right-trim " "(apply 'strcat (mapcar '(lambda (x) (strcat x " ")) jp_lst)))) (setq choice (getkword (strcat "["(vl-string-right-trim "/"(apply 'strcat (mapcar '(lambda (x) (strcat x "/")) jp_lst)))"] <" (cdr (assoc ml_just j_lst)) "> : "))) (cond ( (= choice "Top") (setq ml_just 0)) ( (= choice "Middle") (setq ml_just 1)) ( (= choice "Bottom") (setq ml_just 2)) );end_cond (vlax-put-property ml_obj 'justification ml_just) (setvar 'dynprompt dynp) (setvar 'dynmode dynm) (if (and c_doc (= 8 (logand 8 (getvar 'UNDOCTL)))) (vla-endundomark c_doc)) (princ) );end_defun Edited October 16, 2018 by dlanorh code updated Quote
marmo Posted October 17, 2018 Author Posted October 17, 2018 Thankyou dlanorh but the lisp not useful for my purpose because when you change the justification the mline moves accordingly to the new justification. Instead I would like to change the justification without moving the mline. That is the problem. Quote
marmo Posted October 17, 2018 Author Posted October 17, 2018 19 hours ago, ronjonp said: Post an example drawing. Hi ronjonp, I think that it's not necessary. To verify that is enough: 1) draw an mline 2) open the properties panel 3) look at the justification row at the bottom of the properties panel 4) change directly from the panel the justification of the mline (you have 3 possible choises : Top, bottom, zero) 5) when you do that you see that the mline moves accordingly! The question is to change the justification point and keep fixed the position of the mline. Thankyou :) Quote
marmo Posted October 17, 2018 Author Posted October 17, 2018 (edited) https://forums.autodesk.com/t5/autocad-forum/changing-mline-grip-to-center/td-p/7183627 This one shows more or less the question I'm writing about. At the end they say that is not possible to change the position of the grip whitout changing the geometry of the mline. Is it ALWAYS true? There is a way via lisp to solve the problem? For example for texts you can use the both ways, you can change the grip position with or without moving the text. Edited October 17, 2018 by marmo Quote
dlanorh Posted October 17, 2018 Posted October 17, 2018 (edited) 2 hours ago, marmo said: https://forums.autodesk.com/t5/autocad-forum/changing-mline-grip-to-center/td-p/7183627 This one shows more or less the question I'm writing about. At the end they say that is not possible to change the position of the grip whitout changing the geometry of the mline. Is it ALWAYS true? There is a way via lisp to solve the problem? For example for texts you can use the both ways, you can change the grip position with or without moving the text. Changing the justification of a mline changes the geometry of the mline since the mline coordinates remain the same no matter the justification; and the grips remain at the vertices. The lines change to accomodate the new justification. You can extract the mline coordinates, its current justification and width (MLineScale property). It may then be possible to draw a pline through the coordinates, offset that by the required distance for the new justification and constructing a new mline using the coords of the offset line with the required justification; or simply write the new coordinates back into the existing mline and change the justification. Having never done that, I couldn't say if the new mline would exactly follow the old mline. Bottom justification is always to the right of the direction in which it was constructed. Edited October 17, 2018 by dlanorh Quote
ronjonp Posted October 17, 2018 Posted October 17, 2018 Maybe a hack like this .. definitely works with two point mlines: (defun c:foo (/ a b i o s) ;; RJP » 2018-10-17 (cond ((setq s (ssget ":L" '((0 . "mline")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object x)) (setq i (vla-get-justification o)) (vla-getboundingbox o 'a z) (setq b a) (vla-put-justification o (if (< i 2) (1+ i) 0 ) ) (vla-update o) (vla-getboundingbox o 'a z) (vla-move o a b) ) (sssetfirst nil s) ) ) (princ) ) 1 Quote
ronjonp Posted October 17, 2018 Posted October 17, 2018 Here's a version where you can choose the justification: (defun c:foo (/ a b c d i o s) ;; RJP » 2018-10-17 (setq c '("Top" "Zero" "Bottom")) (initget "Top Zero Bottom") (setq d (cond ((getkword "\nEnter justification [Top/Zero/Bottom]<Top>:")) ("Top") ) ) (cond ((setq s (ssget ":L" '((0 . "mline")))) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq o (vlax-ename->vla-object x)) (setq i (vla-get-justification o)) (vla-getboundingbox o 'a z) (setq b a) (vla-put-justification o (vl-position d c)) (vla-update o) (vla-getboundingbox o 'a z) (vla-move o a b) ) ) ) (princ) ) 1 Quote
Lee Mac Posted October 17, 2018 Posted October 17, 2018 (edited) You could try my new Multiline Justification program: Edited October 17, 2018 by Lee Mac 2 Quote
marmo Posted October 19, 2018 Author Posted October 19, 2018 Perfect! Thank you guys! You are geniuses! Quote
marmo Posted November 8, 2018 Author Posted November 8, 2018 On 10/18/2018 at 12:17 AM, Lee Mac said: You could try my new Multiline Justification program: For some reasons it doesn't work in this file. It changes the geometries. test MLJUST.dwg Quote
Lee Mac Posted November 8, 2018 Posted November 8, 2018 2 hours ago, marmo said: For some reasons it doesn't work in this file. It changes the geometries. test MLJUST.dwg This is not a problem with my MLJUST program, but rather a problem or corruption with the Multiline Styles in your drawing - if you change the MLine justification using the AutoCAD Properties Palette you will receive the same result as with my program. Quote
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.