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 (176 Views)

Writing a file path to a *. txt file

176 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: 2,667
Registered: ‎12-17-2004
Message 2 of 5 (173 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 (167 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: 2,667
Registered: ‎12-17-2004
Message 4 of 5 (163 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: 63
Registered: ‎02-20-2011
Message 5 of 5 (154 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.

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community