leonucadomi Posted July 4, 2022 Posted July 4, 2022 is there any way to put the text from mtext to a multileader? I have to do it repeatedly... help thanks test.dwg Quote
exceed Posted July 4, 2022 Posted July 4, 2022 54 minutes ago, leonucadomi said: is there any way to put the text from mtext to a multileader? I have to do it repeatedly... help thanks test.dwg 44.81 kB · 0 downloads (defun c:foo ( / ss ssl get1ss obj gettext ss2 ss2l index enamemleader objmleader ) (princ "\n select original text or mtext") (setq ss (ssget '((0 . "*text")))) (setq ssl (sslength ss)) (setq get1ss (ssname ss (- ssl 1))) (setq obj (vlax-ename->vla-object get1ss)) (setq gettext (vlax-get-property obj 'textstring)) (princ "\n select object multileaders") (setq ss2 (ssget '((0 . "multileader")))) (setq ss2l (sslength ss2)) (setq index 0) (repeat ss2l (setq enamemleader (ssname ss2 index)) (setq objmleader (vlax-ename->vla-object enamemleader)) (vlax-put-property objmleader 'textstring gettext) (setq index (+ index 1)) ) (princ) ) you can start with this 1 Quote
Steven P Posted July 4, 2022 Posted July 4, 2022 I'd be tempted to do the repeat from the beginning and instead of ssget use entget or ssget with filter to get a single object only - might make it easier for the user rather than having to remember the order they selected the mtexts in to do it direct one for one changes Quote
leonucadomi Posted July 4, 2022 Author Posted July 4, 2022 I would like you to do it one by one instead of doing it in groups. Quote
leonucadomi Posted July 4, 2022 Author Posted July 4, 2022 (defun c:foo ( / ss ssl get1ss obj gettext ss2 ss2l index enamemleader objmleader ) (repeat 100 (princ "\n select original text or mtext") (setq ss (ssget "_+.:E:S" '((0 . "*text")))) (setq ssl (sslength ss)) (setq get1ss (ssname ss (- ssl 1))) (setq obj (vlax-ename->vla-object get1ss)) (setq gettext (vlax-get-property obj 'textstring)) (princ "\n select object multileaders") (setq ss2 (ssget "_+.:E:S" '((0 . "multileader")))) (setq ss2l (sslength ss2)) (setq index 0) (repeat ss2l (setq enamemleader (ssname ss2 index)) (setq objmleader (vlax-ename->vla-object enamemleader)) (vlax-put-property objmleader 'textstring gettext) (setq index (+ index 1)) ) (princ) );repeat ); defun 1 Quote
exceed Posted July 4, 2022 Posted July 4, 2022 Using entsel or ssget :E:S is more standard in this case. you are correct it's just my habit. haha I often use ssget to select a window even if when I select only one. because that's personally less likely to make a mistake. (cancel when I select another place, or to not be able to exclude it with shift is more uncomfortable for me) 2 Quote
Steven P Posted July 4, 2022 Posted July 4, 2022 Yup, know what you mean, we all have our own ways that work for each of us 1 Quote
exceed Posted July 4, 2022 Posted July 4, 2022 43 minutes ago, leonucadomi said: (defun c:foo ( / ss ssl get1ss obj gettext ss2 ss2l index enamemleader objmleader ) (repeat 100 (princ "\n select original text or mtext") (setq ss (ssget "_+.:E:S" '((0 . "*text")))) (setq ssl (sslength ss)) (setq get1ss (ssname ss (- ssl 1))) (setq obj (vlax-ename->vla-object get1ss)) (setq gettext (vlax-get-property obj 'textstring)) (princ "\n select object multileaders") (setq ss2 (ssget "_+.:E:S" '((0 . "multileader")))) (setq ss2l (sslength ss2)) (setq index 0) (repeat ss2l (setq enamemleader (ssname ss2 index)) (setq objmleader (vlax-ename->vla-object enamemleader)) (vlax-put-property objmleader 'textstring gettext) (setq index (+ index 1)) ) (princ) );repeat ); defun You did a good job. If you add (c:foo) above (princ) at the end rather than (repeat 100 it will repeat until you hit esc. like this (defun c:foo ( / ss ssl get1ss obj gettext ss2 ss2l index enamemleader objmleader ) (princ "\n select original text or mtext") (setq ss (ssget "_+.:E:S" '((0 . "*text")))) (setq ssl (sslength ss)) (setq get1ss (ssname ss (- ssl 1))) (setq obj (vlax-ename->vla-object get1ss)) (setq gettext (vlax-get-property obj 'textstring)) (princ "\n select object multileaders") (setq ss2 (ssget "_+.:E:S" '((0 . "multileader")))) (setq ss2l (sslength ss2)) (setq index 0) (repeat ss2l (setq enamemleader (ssname ss2 index)) (setq objmleader (vlax-ename->vla-object enamemleader)) (vlax-put-property objmleader 'textstring gettext) (setq index (+ index 1)) ) (c:foo) (princ) ); defun and It's better to put your code inside a code form. It is a <> icon at the top of the writing tool. 1 Quote
leonucadomi Posted July 4, 2022 Author Posted July 4, 2022 excellent that's why I love this forum thank you all Quote
BIGAL Posted July 5, 2022 Posted July 5, 2022 My $0.05 (while (setq ss (ssget "_+.:E:S" '((0 . "*text")))) I will let you work out where the closing ) should go. Move (c:foo) to last line it will run then on load and any time want more just type FOO 1 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.