lisp carries out each instruction within pairs
try
(while (setq new_line (read-line fileopen))
code here
then use variable new_lineif its Nil loop exits
) ;end while Forgot do you now want the code for reading a xyz file, how is your file set up does it use commas to seperate variables or are the x y z a set number of characters ?
100.123, 200,456,300.789
123456789012345678901
100.123 200.456 300.789
Good point AL, and good solution - I must admit, I have never used this method for inserting blocks into drawings, and my posted LISP was untested also. - but thanks for your input. Have you guys figured this one out?
I would be quite keen to use it myself and could provide you with some feedback if necessary (relating to its function, not its code).
currently I use Microstation for this tool. But I plan on doing an all encompassing form driven block/coordinate functions menu when I feel more competent with C#. Hiya Wannabe,
This should worked (although untested!):
(defun c:ITREE (/ *error* file1 blk pts) (defun *error* (msg) (setvar "cmdecho" 1) (if (= msg "") (princ (strcat (itoa blk) " Blocks Inserted.")) (princ "\nError or Esc Pressed.") ) ;_end if ) ;_end defun (selfile) (setvar "cmdecho" 0) (setq file1 (open file "r") blk 0 ) ;_end setq (while (/= (setq pts (read-line file1)) nil) (command "-insert" "C:\\" ;
The order of the file does not matter because I can export to any format, (i.e. xyz, yxz, etc and comma, tab or space delimited). My preference though would be yxz comma delimited. Here is two example the first uses fixed lengths for x yx z etc (please note code wont work as is but can be used within you program check brackets etc)
(defun lay_name () (setq ans "") (setq char_found "") (while (/= x y) (setq char_found (substr new_line x 1)) (setq x (+ x 1)); (if (= char_found (chr 92)) (if (= char_found " ") (setq x y) (setq ans (strcat ans char_found)) ) ))(while (setq new_line (read-line fo)) (setq x 1) (setq y 17) (lay_name) (setq new_name ans ) (setq x 17) (setq y 32) (lay_name) (setq name ans) (setq x 33) (setq y 36) (lay_name) (setq col ans) (setq x 37) (setq y 47) (lay_name) (setq line ans) (setq ans_var (strcat "(" "setq" name " " (chr 34)new_name (chr 34) ")" )) (setq ans_col (strcat "(" "setq" (strcat name "col") " "col ")" ))(setq ans_line (strcat "(" "setq" (strcat name "lin") " "(chr 34) line (chr 34) ")" ))
2nd example is comma delimted
(defun xyz () (setq ans "") (setq char_found "") (while (/= char_found ",") (setq char_found (substr new_line x 1)) (setq x (+ x 1)) (setq ans (strcat ans char_found)) ) ;end while) ;end defun (defun xyzend () (setq ans "") (setq char_found "") (while (/= char_found (chr 13)) (setq char_found (substr new_line x 1)) (setq x (+ x 1)) (setq ans (strcat ans char_found)) ) ;end while) ;end(setq xyzfiles (getfiled "\nENTER CO-ORD File name" "" "" 4))(setq fopen (open xyzfiles "R"))(SETQ XX 1)(while (setq new_line (read-line fopen))(PRINC XX) (setq x 1) (setq y 5) (xyz) (setq ptno ans) ;pull ptno out (xyz) (setq easting ans) (xyz) (setq northing ans) (xyzend) (setq height ans)
页:
1
[2]