乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 40|回复: 4

[编程交流] Error: bad argument type: outp

[复制链接]

28

主题

118

帖子

95

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
136
发表于 2022-7-5 15:57:11 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

rlx

21

主题

1505

帖子

1551

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
81
发表于 2022-7-5 16:18:04 | 显示全部楼层
You try to write to the file-name (fnm) when you should write to the file-pointer (opn)
 
 
 
 
gr.Rlx
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 16:28:27 | 显示全部楼层
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.
 
  1. (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)
回复

使用道具 举报

28

主题

118

帖子

95

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
136
发表于 2022-7-5 16:55:08 | 显示全部楼层
Thank you for your help guys.
 
 
Tharwat, I like your alternative solution using vlax-invoke and 'getattributes.
 
 
Always learning..
 
 
Thanks again.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 17:00:44 | 显示全部楼层
You're welcome.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-13 21:23 , Processed in 0.972019 second(s), 62 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表