Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

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

vl-string-subst

345 Views, 3 Replies
01-18-2013 07:37 AM

Hi,

 

I have a lisp program that find all texts with xxxx/yyyy pattern in current drawing and save all of them in a TEXT file line by line. (each text in one line).

 

I want to replace "/" with ",/," when the program writes this Texts to the *.CSV via vl-string-subst function.

 

So, I add (vl-string-subst ",/," "/" itm) to this lisp program.

But it doesn't work and makes an error.

 

Can anybody help me?

 

Thanks,

 

(defun c:W2csv (/ strs fname file i)
(if (and (= (getvar 'DwgTitled) 1)
(setq strs nil
ss (ssget (list '(0 . "TEXT") (cons 1 "*/*"))))
(setq fname (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv"))
(setq file (open fname "w"))
)
(progn
(repeat (setq i (sslength ss))
(setq strs (cons (cdr (assoc 1 (entget (ssname ss (setq i (1- i)))))) strs))
)

(foreach itm (vl-sort strs '<))
(write-line (vl-string-subst ",/," "/" itm) file)
)
(close file)
(startapp "Notepad" fname)
)
)
(princ)
)

 


aqdam1978 wrote:

Hi,

 

I have a lisp program that find all texts with xxxx/yyyy pattern in current drawing and save all of them in a TEXT file line by line. (each text in one line).

 

I want to replace "/" with ",/," when the program writes this Texts to the *.CSV via vl-string-subst function.

 

So, I add (vl-string-subst ",/," "/" itm) to this lisp program.

But it doesn't work and makes an error.

 

Can anybody help me?

 

Thanks,

 

 


You prematurely close the foreach line here

 

(foreach itm (vl-sort strs '<));<----

 

 

 

*Expert Elite*
pbejse
Posts: 2,502
Registered: ‎11-24-2009
Message 2 of 4 (339 Views)

Re: vl-string-subst

01-18-2013 07:54 AM in reply to: aqdam1978

aqdam1978 wrote:

Hi,

 

I have a lisp program that find all texts with xxxx/yyyy pattern in current drawing and save all of them in a TEXT file line by line. (each text in one line).

 

I want to replace "/" with ",/," when the program writes this Texts to the *.CSV via vl-string-subst function.

 

So, I add (vl-string-subst ",/," "/" itm) to this lisp program.

But it doesn't work and makes an error.

 

Can anybody help me?

 

Thanks,

 

 


You prematurely close the foreach line here

 

(foreach itm (vl-sort strs '<));<----

 

 

 

Mentor
aqdam1978
Posts: 265
Registered: ‎11-05-2008
Message 3 of 4 (327 Views)

Re: vl-string-subst

01-18-2013 09:29 AM in reply to: pbejse

Hi,

 

Thank you so much.

 

*Expert Elite*
pbejse
Posts: 2,502
Registered: ‎11-24-2009
Message 4 of 4 (301 Views)

Re: vl-string-subst

01-19-2013 07:00 AM in reply to: aqdam1978

aqdam1978 wrote:

Hi,

 

Thank you so much.

 


You are welcome.

 

I'm happy to help. :smileyhappy:

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!