Visual LISP, AutoLISP and General Customization

Reply
Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 1 of 7 (196 Views)
Accepted Solution

adding a text to selected texts

196 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.

 

 

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 2 of 7 (192 Views)

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*
3wood
Posts: 969
Registered: ‎03-25-2009
Message 3 of 7 (183 Views)

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
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 4 of 7 (173 Views)

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
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 5 of 7 (171 Views)

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*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 6 of 7 (155 Views)

Re: adding a text to selected texts

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

You're welcome,  aqdam1978

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 7 of 7 (142 Views)

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

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community