Jump to content

Recommended Posts

Posted

is there any way to put the text from mtext to a multileader?

 

I have to do it repeatedly...

 

 

help 

 

 

thanks

test.dwg

Posted
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

  • Like 1
Posted

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

Posted

I would like you to do it one by one instead of doing it in groups.

Posted

(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

  • Like 1
Posted

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)

  • Like 2
Posted

Yup, know what you mean, we all have our own ways that work for each of us

  • Like 1
Posted
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.

 

  • Like 1
Posted

excellent that's why I love this forum thank you all

Posted

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

 

 

 

  • Like 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...