Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
The_Caddie
Posts: 208
Registered: ‎06-08-2010
Message 1 of 5 (198 Views)

Writing a file path to a *. txt file

198 Views, 4 Replies
12-20-2012 01:57 AM

I have a file path im trying to capture in a text file however its not working and autocad is prompting back,

 

; error bad argument type: streamp nil

 Im assuming its because of the slashbacks but Im not sure..

 

Herse the code sofar...

 

(defun C:GO ()

(SETQ ACADLSP (findfile "acad.lsp"))
(setq f (open "C:\test.txt" "w"))
(write-line ACADLSP f)
(close f)

)
*Expert Elite*
hmsilva
Posts: 3,336
Registered: ‎12-17-2004
Message 2 of 5 (195 Views)

Re: Writing a file path to a *. txt file

12-20-2012 02:14 AM in reply to: The_Caddie

change

 

"C:\Test.txt"

 

to

 

"C:\\Test.txt""

 

Henrique

Mentor
The_Caddie
Posts: 208
Registered: ‎06-08-2010
Message 3 of 5 (189 Views)

Re: Writing a file path to a *. txt file

12-20-2012 02:32 AM in reply to: hmsilva

nope that aint it ( i noted that you accidentaly added an extra double quote) though still didnt work.

*Expert Elite*
hmsilva
Posts: 3,336
Registered: ‎12-17-2004
Message 4 of 5 (185 Views)

Re: Writing a file path to a *. txt file

12-20-2012 02:37 AM in reply to: The_Caddie

this works for me

 

(defun C:GO ()
  (SETQ ACADLSP (findfile "acad.lsp"))
  (setq f (open "C:\\test.txt" "w"))
  (write-line ACADLSP f)
  (close f)
)

 

Valued Contributor
dicra
Posts: 90
Registered: ‎02-20-2011
Message 5 of 5 (176 Views)

Re: Writing a file path to a *. txt file

12-20-2012 03:24 AM in reply to: The_Caddie

Try to run autocad as administrator,

 

I was having the same problem, I could create file on "D:" , but could not on "C:".

I think that is your problem, because I think that you cannot create a file on "C:" if you don't run autocad as administrator.

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.