Hi friends ,in this article i will explain about how to get
the path of the file in AutoLISP.
First of all open
the Visual LISP Editor,If you want to know about how to open Visual LISP Editor in
AutoCAD.
(defun c:file()
(Setq file_chk 1)
(while (= file_chk 1)
(setq f_name "")
(while (= f_name "")
(setq f_name (getstring "\nEnter
the File name:"))
)
(Setq file_name (strcat f_name
".fot"))
(Setq f1 (strcat "\\"
file_name))
(setq f1 (open f1 "r"))
(if (= f1 nil)
(alert "File Does Not Exist")
(Setq file_chk 0)
)
)
)
|
Save the file as file.LSP
Then write the
below line in the AutoCAD Command prompt.
Command: (load “file”)
Command:file
|
Then it will ask the following in the command and press ENTER.
Enter the File name:file
|
Then we can get the data in this file.It loaded in the
program ,we can read this file using read-line
or read –char.
If you want to get the file from in the folder then write
the following code.
(defun c:file()
(Setq file_chk 1)
(while (= file_chk 1)
(setq d_name "")
(while (= d_name "")
(setq d_name (getstring "\nEnter
the directory name:"))
)
(setq f_name "")
(while (= f_name "")
(setq f_name (getstring "\nEnter
the File name:"))
)
(Setq fot_fd (strcat f_name
".fot"))
(Setq fot_fd (strcat "c:\\"
d_name "\\" fot_fd))
(setq fot_fd (open fot_fd
"r"))
(if (= fot_fd nil)
(alert "File Does Not Exist")
(Setq file_chk 0)
)
)
)
|
Happy Reading my blog.If you have any doubts ,appreciation then
please put the doubt or appreciation as a
comment.
code:
ReplyDelete(getfiled "Title" "Directory Path and/or File name" "File Extension" Flag)
(setq ARQUIVO (open "C:\\TEMP\\CID.txt" "r"))
sample:
(setq ARQUIVO (getfiled "Buscando o arquivo de dados..." (getvar "DWGPREFIX") "TXT;CSV;SCP;*" 0))
(open ARQUIVO "r")
Thank U My for your reply..........
Delete