Jump to content

Error: bad argument type: output-streamp:


abra-CAD-abra

Recommended Posts

All,

 

I am battling with this error and I cannot find much documentation on it:

Error: bad argument type: output-streamp: "C:\\Coords\\test.csv"

 

I cannot see any problems with my code although I suspect it may be something to do with getfiled?

 

Anybody have any suggestions?

 

Please refer attached LISP.

 

Thanks in advance

C2Ex.lsp

Link to comment
Share on other sites

Hi,

 

The error you have been receiving is due to writing to file name and not to file-pointer as Rlx mentioned above, so I rewrote 'your' codes in another way and hope you don't mind since the following code and is more than enough and faster than converting safearray to list and so on.

 

(defun c:test (/ *error* opn s fnm i e ip)
 (defun *error* (msg)
   (if opn (close opn))
   (and msg (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
     (princ (strcat "\nError: " msg))
   )
   (princ)
 )
 (if (and (setq s (ssget "_:L" '((0 . "INSERT") (66 . 1))))
          (setq fnm (getfiled "Save Coordinates to Text or CSV File" "" "csv;txt" 1))
          (setq opn (open fnm "w"))
          )
   (repeat (setq i (sslength s))
       (setq e (vlax-ename->vla-object (ssname s (setq i (1- i))))
             ip (vlax-get e 'insertionpoint))
      (write-line (strcat (vla-get-textstring (car (vlax-invoke e 'getattributes)))
                          "," (rtos (car ip) 2 4)
                          "," (rtos (cadr ip) 2 4)) opn)
     )
   )
 (*error* nil)
 (princ)
) (vl-load-com)

Link to comment
Share on other sites

Thank you for your help guys.

 

 

Tharwat, I like your alternative solution using vlax-invoke and 'getattributes.

 

 

Always learning..

 

 

Thanks again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...