PDA

View Full Version : request: code to change text in the file



guest
25th Jun 2005, 09:12 am
Hi,

I need a lisp code to do the following:

I have dwg file. And in original file there is a text let's say "XX". I want to make copies of this file such that the text "XX" is changed to "XX001" in the first copy, "XX002" in the second copy,.....,"XX100" in the 100th copy.

I would be grateful if someone could post a lisp code to achieve this.

Adesu
7th Jul 2005, 02:45 am
Hi,

I need a lisp code to do the following:

I have dwg file. And in original file there is a text let's say "XX". I want to make copies of this file such that the text "XX" is changed to "XX001" in the first copy, "XX002" in the second copy,.....,"XX100" in the 100th copy.

I would be grateful if someone could post a lisp code to achieve this.

Hi guest,maybe my script useful for, here this code


; cf is stand for create copy file at same folder
; Design by Ade Suharna <mteybid@yuasabattery.co.id>
; 6 July 2005
; Programe no.245/07/2005
; Edit by
&#40;defun c&#58;cf &#40;/ dn str_len num ext_dn dwg cnt n new_dn loc_file new_lf&#41;
&#40;setq dn &#40;getvar "dwgname"&#41;&#41;
&#40;setq str_len &#40;strlen dn&#41;&#41;
&#40;setq num &#40;- str_len 4&#41;&#41;
&#40;setq ext_dn &#40;substr dn 1 num&#41;&#41;
&#40;setq dwg ".dwg"&#41;
&#40;setq cnt 0&#41;
&#40;setq n &#40;getint "\nHOW MANY COPY DO YOU WANT <100>&#58; "&#41;&#41;
&#40;if &#40;= n nil&#41;&#40;setq n 100&#41;&#41;
&#40;repeat n
&#40;setq new_dn &#40;strcat ext_dn "-" &#40;itoa cnt&#41; dwg&#41;&#41;
&#40;setq loc_file &#40;strcat &#40;getvar "dwgprefix"&#41;&#40;getvar "dwgname"&#41;&#41;&#41;
&#40;setq new_lf &#40;strcat &#40;getvar "dwgprefix"&#41; new_dn&#41;&#41;
&#40;vl-file-copy loc_file new_lf&#41;
&#40;setq cnt &#40;1+ cnt&#41;&#41;
&#41;
&#41;

guest
7th Jul 2005, 07:44 am
Thanks Adesu. This solves part of the problem. But the problem with the text edit still remains. I would appreciate any help on that.

dunkydolittle
19th Nov 2005, 08:04 pm
I would be very interested to hear more on how you overcame your problem. I have a near identical problem, any help much appreciated will try and run the lisp but i am a newcomer to autolisp.