As Paul pointed out, the while is never ending.
By incresing cnt by 1 and using repeat ,you are reading the first
record the first time, then you read the next two, then the next 3, etc.
You are setting crown to what you read to use as a scale factor,
so apparently the file you have has a set of records with different
scale factors. When you reach the end of the file the scale factor
will not be correct. Once you get to the end you continue to try to
read the file, setting the scale factor to whatever garbage it finds at the
end of the file. This is probably where your error is.
Try this (untested)
(defun C:ITE (/ symbol i_point Crown t_type treeno jobno tfnam fnam)
(setq
oldecho (getvar "cmdecho")
oldblip (getvar "blipmode")
oldclyr (getvar "clayer")
)
(setq jobno (substr (getvar "dwgname") 1 5))
(setq tfnam (strcat jobno ".txt"))
(setq i_point (getpoint "\nSelect insertion point: "))
(setq treeno (getint "\nEnter Tree No: "))
(command "insert" symbol i_point Crown Crown "" treeno)
(set cnt 1)
(setq i_point (getpoint "\nSelect insertion point: "))
(setq treeno (getint "\nEnter Tree No: "))
(command "insert" symbol i_point Crown Crown "" treeno)
(setq fnam (open tfnam "r"))
(if (not (tblsearch "LAYER" "EJK_SYMBOL_EXISTING"))
(command "LAYER" "N" "EJK_SYMBOL_EXISTING" "")
)
(setvar "clayer" "EJK_SYMBOL_EXISTING")
(setq symbol "ejk_t_ex_dec_1")
(while
(setq Crown (atoi (read-line fnam)))
(setq i_point (getpoint "\nSelect insertion point: "))
(command "insert" symbol i_point Crown Crown "" treeno)
(setq treeno (+ treeno 1))
)
(close fnam)
(setvar "cmdecho" oldecho)
(setvar "blipmode" oldblip)
(setvar "clayer" oldclyr)
(princ)
)
If you really only have one record in the txt file indicating the
scale factor to use for all inserts and you want the while to
continue until you quit selecting locations, then try this (untested).
(defun C:ITE (/ symbol i_point Crown t_type treeno jobno tfnam fnam)
(setq
oldecho (getvar "cmdecho")
oldblip (getvar "blipmode")
oldclyr (getvar "clayer")
)
(setq jobno (substr (getvar "dwgname") 1 5))
(setq tfnam (strcat jobno ".txt"))
(setq i_point (getpoint "\nSelect insertion point: "))
(setq treeno (getint "\nEnter Tree No: "))
(command "insert" symbol i_point Crown Crown "" treeno)
(set cnt 1)
(setq i_point (getpoint "\nSelect insertion point: "))
(setq treeno (getint "\nEnter Tree No: "))
(command "insert" symbol i_point Crown Crown "" treeno)
(setq fnam (open tfnam "r"))
(if (not (tblsearch "LAYER" "EJK_SYMBOL_EXISTING"))
(command "LAYER" "N" "EJK_SYMBOL_EXISTING" "")
)
(setvar "clayer" "EJK_SYMBOL_EXISTING")
(setq symbol "ejk_t_ex_dec_1")
(setq treeno (getint "\nEnter Tree No: "))
(setq Crown (atoi (read-line fnam)))
(close fnam)
(while
(setq i_point (getpoint "\nSelect insertion point: "))
(command "insert" symbol i_point Crown Crown "" treeno)
(setq treeno (+ treeno 1))
)
(setvar "cmdecho" oldecho)
(setvar "blipmode" oldblip)
(setvar "clayer" oldclyr)
(princ)
)
wrote in message news:5177892@discussion.autodesk.com...
Thanks for the help. Now when I type in !Crown it is set to "ÿþ3\0000\000"
Any Clues? Is this ASCII for 20 ? The external file I want to read is just
a bunch of numbers.
Kdoug