Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
syria89
Posts: 645
Registered: ‎03-09-2007
Message 1 of 3 (454 Views)
Accepted Solution

what'S wrong with this lisp to import excel x y to cad

454 Views, 2 Replies
02-21-2012 11:47 AM

i attached a lsp with and excel

the lsp does creat circles with diameter of 5 related to imported points from excel

i realsed that it is able to get the first column but can get the coordinate from the second one

                (setq posX (atof (substr line 1 nPos)))  (this is ok)
                (setq posY (atof (substr line (1+ nPos)))) (not this one)

 


syria89 wrote:

....

the lsp does creat circles with diameter of 5 related to imported points from excel

i realsed that it is able to get the first column but can get the coordinate from the second one

                (setq posX (atof (substr line 1 nPos)))  (this is ok)
                (setq posY (atof (substr line (1+ nPos)))) (not this one)

 


Given this line [the first one]:
 

288390.6;5052934

 

and that nPos has been set by this:

 

(setq nPos (vl-string-position (ascii ";") line))

 

then nPos will be 8, and posX will be 288390.6.  But you want posY to be read starting at the tenth position, not the ninth, because (substr) counts the first character as 1, whereas (vl-string-position counts it as 0.  Try:
 

                (setq posY (atof (substr line (+ nPos 2))))

*Expert Elite*
Kent1Cooper
Posts: 5,796
Registered: ‎09-13-2004
Message 2 of 3 (447 Views)

Re: what'S wrong with this lisp to import excel x y to cad

02-21-2012 12:01 PM in reply to: syria89

syria89 wrote:

....

the lsp does creat circles with diameter of 5 related to imported points from excel

i realsed that it is able to get the first column but can get the coordinate from the second one

                (setq posX (atof (substr line 1 nPos)))  (this is ok)
                (setq posY (atof (substr line (1+ nPos)))) (not this one)

 


Given this line [the first one]:
 

288390.6;5052934

 

and that nPos has been set by this:

 

(setq nPos (vl-string-position (ascii ";") line))

 

then nPos will be 8, and posX will be 288390.6.  But you want posY to be read starting at the tenth position, not the ninth, because (substr) counts the first character as 1, whereas (vl-string-position counts it as 0.  Try:
 

                (setq posY (atof (substr line (+ nPos 2))))

Kent Cooper
Distinguished Contributor
syria89
Posts: 645
Registered: ‎03-09-2007
Message 3 of 3 (442 Views)

Re: what'S wrong with this lisp to import excel x y to cad

02-21-2012 12:15 PM in reply to: Kent1Cooper

A BIG THANKS

:robothappy:

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!