Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

adding a text to selected texts

205 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*
hmsilva
Posts: 3,046
Registered: ‎12-17-2004
Message 2 of 7 (201 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: 1,095
Registered: ‎03-25-2009
Message 3 of 7 (192 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 (182 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 (180 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: 3,046
Registered: ‎12-17-2004
Message 6 of 7 (164 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,500
Registered: ‎11-24-2009
Message 7 of 7 (151 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

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.