乐筑天下

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

[编程交流] debug help :bad argument type:

[复制链接]

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 06:41:15 | 显示全部楼层 |阅读模式
Hi
 
this code is trying to distribute points along a polyline.
 
  1. (Defun c:demo (/ pline int in pt ppt mspace thepoint) (if (and (setq pline (car (entsel "\nSelect Polyline:")))      (eq (cdr (assoc 0 (entget pline))) "LWPOLYLINE")      (setq int (getdist "\nEnter Interval:"))      (setq in int)     )   (while (Setq pt (vlax-curve-getPointAtDist pline int))     (setq ppt (vlax-curve-getparamatpoint pline pt))     (vlax-invoke   (vlax-ename->vla-object pline)   (setq mspace (vla-get-modelspace              (vla-get-activedocument            (vlax-get-acad-object)              )            )   )   (princ ppt)   (setq thepoint (vla-AddPoint mspace (vlax-3d-point pt)))   (1+ (fix ppt))   (list (car pt) (Cadr pt))     )     (setq int (+ int in))   ) ))
why its yell an error?
 
Thanks
Shay
回复

使用道具 举报

35

主题

2471

帖子

2447

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
174
发表于 2022-7-6 07:01:40 | 显示全部楼层
I believe that you don't need that VLAX-INVOKE(-METHOD); also is better to don't create the space object at each parse:
  1. (Defun c:demo (/ pline int in pt ppt mspace thepoint) (if (and (setq pline (car (entsel "\nSelect Polyline:")))      (eq (cdr (assoc 0 (entget pline))) "LWPOLYLINE")      (setq int (getdist "\nEnter Interval:"))      (setq in int)     )[color=red]   (progn[/color][color=magenta]    (setq mspace (vla-get-modelspace              (vla-get-activedocument            (vlax-get-acad-object)              )            )[/color]    (while (Setq pt (vlax-curve-getPointAtDist pline int))     (setq ppt (vlax-curve-getparamatpoint pline pt))[color=red]      ;(vlax-invoke[/color]    (vlax-ename->vla-object pline)   )   (princ ppt)   (setq thepoint (vla-AddPoint mspace (vlax-3d-point pt)))   (1+ (fix ppt))   (list (car pt) (Cadr pt))[color=red]      [/color]      (setq int (+ int in))   )[color=red]  )[/color] ))
回复

使用道具 举报

pBe

32

主题

2722

帖子

2666

银币

后起之秀

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

铜币
211
发表于 2022-7-6 07:21:26 | 显示全部楼层
 
The use of Vlax-invoke doesnt require you to "convert" the point coordinate to a variant 3D point. [vlax-3D-point]. so it wouldn't hurt to use it at all.
Also, on what your wanting to do, no need for vlax-curve-getparamatpoint
 
  1. (Defun c:demo (/ pline int in pt ppt mspace thepoint) (if (and (setq pline (car (entsel "\nSelect Polyline:")))   (eq (cdr (assoc 0 (entget pline))) "LWPOLYLINE")   (setq int (getdist "\nEnter Interval:"))   (setq in int)     )   (progn     (setq mspace (vla-get-modelspace             (vla-get-activedocument               (vlax-get-acad-object)             )           )     )     (while (Setq pt (vlax-curve-getPointAtDist pline int))(setq thepoint (vlax-invoke mspace 'AddPoint pt))(setq int (+ int in))     )   ) )(princ))
 
But then again. why not use _measure command.
回复

使用道具 举报

218

主题

699

帖子

483

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1090
发表于 2022-7-6 07:31:33 | 显示全部楼层
 
i thought that using command line is slower than programming it, am i mistaken? how can i store all the coordinates of the distributed points than?
 
Thanks
Shay
回复

使用道具 举报

gS7

35

主题

244

帖子

212

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
180
发表于 2022-7-6 07:50:38 | 显示全部楼层
 
  1. (Setq lst nil)  (setq lst (cons pt lst))
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 15:21 , Processed in 0.484828 second(s), 62 queries .

© 2020-2025 乐筑天下

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