Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
265 Posts
9 Kudos
Registered: ‎11-05-2008
Post 1 of 7
Accepted Solution

adding a text to selected texts

209 Views, 6 Replies
01-24-2013 03:50 PM

Hi,

 

I need a LISP program to add a text given by user to all selected text.

in other words:

1- user selects some texts.

2- user give a text to program.

3- Program added this text to all selected text.

 

selected text: text1, text2, text3,text4,....,textn

given text by user: _xyz

Result:

text1_xyz, text2_xyz, text3_xyz,text4_xyz,....,textn_xyz

 

Can anybody help me?

 

Thanks.

 

 

maybe something like

 

(defun c:test (/ ss nstr str itm obj)
(vl-load-com)
(prompt "\nSelect texts to adda string: ")
(if (and (setq ss (ssget "_:L" '((0 . "TEXT"))))
(setq
nstr (getstring "\nEnter the string to add to the text: ")
)
)
(repeat (setq itm (sslength ss))
(setq
obj (vlax-ename->vla-object (ssname ss (setq itm (1- itm))))
)
(setq str (vla-get-textstring obj))
(vla-put-textstring obj (strcat str nstr))
);; repeat
);; if
(princ)
)

 

hope that helps

 

Henrique

*Expert Elite*
3,545 Posts
535 Kudos
Registered: ‎12-17-2004
Post 2 of 7

Re: adding a text to selected texts

01-24-2013 04:11 PM in reply to: aqdam1978

maybe something like

 

(defun c:test	(/ ss nstr str itm obj)
    (vl-load-com)
    (prompt "\nSelect texts to adda string: ")
    (if	(and (setq ss (ssget "_:L" '((0 . "TEXT"))))
	     (setq
	       nstr (getstring "\nEnter the string to add to the text: ")
	     )
	)
      (repeat (setq itm (sslength ss))
	(setq
	  obj (vlax-ename->vla-object (ssname ss (setq itm (1- itm))))
	)
	(setq str (vla-get-textstring obj))
	(vla-put-textstring obj (strcat str nstr))
      );; repeat
    );; if
    (princ)
  )

 

hope that helps

 

Henrique

*Expert Elite*
1,176 Posts
126 Kudos
Registered: ‎03-25-2009
Post 3 of 7

Re: adding a text to selected texts

01-24-2013 05:36 PM in reply to: aqdam1978

You can try ALTEXT.vlx,

just set "_xyz" as suffix.

altext.png

Mentor
265 Posts
9 Kudos
Registered: ‎11-05-2008
Post 4 of 7

Re: adding a text to selected texts

01-24-2013 08:28 PM in reply to: hmsilva

Hi hmsilva,

 

Your program is GREAT.

 

Thank you very much.

 

Mentor
265 Posts
9 Kudos
Registered: ‎11-05-2008
Post 5 of 7

Re: adding a text to selected texts

01-24-2013 08:32 PM in reply to: 3wood

Hi 3wood,

 

where can I find the "ALTEXT.vlx" file.

is this file free or I should buy it?

 

Thanks

*Expert Elite*
3,545 Posts
535 Kudos
Registered: ‎12-17-2004
Post 6 of 7

Re: adding a text to selected texts

01-25-2013 01:19 AM in reply to: aqdam1978

You're welcome,  aqdam1978

*Expert Elite*
2,535 Posts
306 Kudos
Registered: ‎11-24-2009
Post 7 of 7

Re: adding a text to selected texts

01-25-2013 05:12 AM in reply to: aqdam1978

anothter

 

(defun c:Asuf ( / suf ss i e st l)
(while (not (progn
  		(setq suf (getstring T "\nEnter string to add: "))
  		(if ( eq suf  "") nil suf ))))
(if (setq ss (ssget "_X" '((0 . "*TEXT"))))
	(repeat (setq i (sslength ss))
		(setq e (entget (ssname ss (setq i (1- i))))
                      st (cdr (assoc 1 e))
          	      l (assoc -1 e))
          	 (entmod (list (cons 1 (strcat st suf)) l)))
	)(princ)
)

 

HTH

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post