; error: bad argument type: output-streamp:

Discussion in 'AutoCAD' started by todbarrett, Feb 9, 2005.

  1. todbarrett

    todbarrett Guest

    Hello LISP experts,

    I'm receiving the error message "; error: bad argument type: output-streamp:" when attempting to write to a file with the WRITE-LINE command that I created with the GETFILED command. I also receive the same message when attempting to close the file.

    I'm attempting to write a comma delimited file of layers in the drawing, extracting the layer name, color, and linetype.

    It would probably be easier to explain if I paste the code:

    (setq layer_file (getfiled "Select Location of TXT file!" "" "txt" 1))
    (princ "\nExporting Layer Name, Color and Linetype to file......")
    (open layer_file "w")
    (setq layer_rec (tblnext "Layer" T))
    (while layer_rec
    (setq layer_name (cdr (assoc 2 layer_rec)))
    (setq layer_color (rtos (cdr (assoc 62 layer_rec))2 0))
    (setq layer_ltype (cdr (assoc 6 layer_rec)))
    (setq layer_info (strcat layer_name "," layer_color "," layer_ltype))
    (write-line layer_info layer_file)
    (setq layer_rec (tblnext "Layer"))
    )
    (close layer_file)

    Thanks very much for your help!!
    Tod
     
    todbarrett, Feb 9, 2005
    #1
  2. todbarrett

    T.Willey Guest

    You never create the txt file. You pick a location but that is it.
    Maybe something liek:

    (setq lay_file (strcat lay_file "Exported-layers.txt"))

    Tim
     
    T.Willey, Feb 10, 2005
    #2
  3. todbarrett

    todbarrett Guest

    Hi Tim,

    The file is created by the following code:
    (setq layer_file (getfiled "Select Location of TXT file!" "" "txt" 1))
    I can browse to the file and see it.
    !layer_file shows "L:\\Acad\\Support\\Civil-layers.txt"

    Command: (open layer_file "w")
    #<file "L:\\Acad\\Support\\Civil-layers.txt">

    So the file is there and open for write, but I can't write to it.
    Perplexed,
    Tod
     
    todbarrett, Feb 10, 2005
    #3
  4. todbarrett

    T.Willey Guest

    Sorry about that. You need to set something to the open file like:

    (setq Opened (open lay_file "w"))
    (write-line layer_info Opened)
    (close Opened)

    Tim
     
    T.Willey, Feb 10, 2005
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.