abra-CAD-abra Posted October 5, 2017 Share Posted October 5, 2017 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 Quote Link to comment Share on other sites More sharing options...
rlx Posted October 5, 2017 Share Posted October 5, 2017 You try to write to the file-name (fnm) when you should write to the file-pointer (opn) gr.Rlx Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 5, 2017 Share Posted October 5, 2017 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) Quote Link to comment Share on other sites More sharing options...
abra-CAD-abra Posted October 6, 2017 Author Share Posted October 6, 2017 Thank you for your help guys. Tharwat, I like your alternative solution using vlax-invoke and 'getattributes. Always learning.. Thanks again. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 6, 2017 Share Posted October 6, 2017 You're welcome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.