Please help: How to read coordinates from a txt file

Feb 01, 2004 1 Replies

I need to read x,y,z coordinates from an ASCII file and then draw points with this coordinates in AutoCAD. Can anybody help me suggesting the AutoLISP function(s) that I should use and the pseudo code or algorithm.



Thanks in advance



Nesha


"Nenad Markovic" schrieb:

... (setq filehandle (open "path/filename" "r")) (while (setq line (read-line filehandle)) ;; if your string is not "x,y,z" ;; then process the string here (setq datalist (cons line datalist)) ) (close filehandle) (foreach pt (reverse datalist) (command "._POINT" pt) ) ...

I don't know how your file is formatted. If it is x,y,z in each single line, then you can pass the string directly to the POINT command, or if you need the coordinates in LISP format then you could substitute (vl-string-subst) the commas with spaces, add (strcat) a leading "(" and a trailing ")" to each line (inside the while loop) and use (setq datalist (cons (read line) datalist))

Tom Berger

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required