乐筑天下

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

[编程交流] What is wrong??? (error: numbe

[复制链接]

21

主题

80

帖子

59

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-6 11:19:53 | 显示全部楼层 |阅读模式
Hi all.
I'm trying to get minimum and maximum values of x coordinate and y coordinate of a polyline in this code. but it returns this error:
error: bad argument type: numberp: nil
Can anyone tell me what is wrong??
thanks....
 

[code] (DEFUN C:TEST (/ NOVERTEX ENTCNT)(SETQ SH (SSGET '((0 . "LWPOLYLINE"))))(SETQ NOVERTEX (CDR (ASSOC 90 (ENTGET (SSNAME SH 0)))))(SETQ VERTEXLISTX (LIST))(SETQ VERTEXLISTY (LIST))(FOREACH A (ENTGET (SSNAME SH 0)) (IF (= 10 (CAR A))  (PROGN   (SETQ VERTEXLISTX    (APPEND VERTEXLISTX (LIST (CADR A)))   );_SETQ   (SETQ VERTEXLISTY    (APPEND VERTEXLISTY (LIST (CADDR A)))   );_SETQ  );_PROGN );_IF);_FOREACH(SETQ ENTCNT 0)(WHILE (
回复

使用道具 举报

5

主题

194

帖子

193

银币

初来乍到

Rank: 1

铜币
24
发表于 2022-7-6 11:37:40 | 显示全部楼层
 
This happens when using (nth  ) when the  is outside the scope of a list
 
Sample
 
  1. (setq tempList (list "abc" "def" "ghi"))(nth 4 tempList)
 
On the final loop
 

[code] (WHILE (
回复

使用道具 举报

5

主题

194

帖子

193

银币

初来乍到

Rank: 1

铜币
24
发表于 2022-7-6 11:42:54 | 显示全部楼层
For an alternative method of sorting the points
 
Swap
 

[code](SETQ ENTCNT 0)(WHILE (
回复

使用道具 举报

21

主题

80

帖子

59

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-6 11:59:45 | 显示全部楼层
Dear jammie,
So thanks for your complete guildance.
Your alternative code is great.
But there is one question:
By increasing "entcnt" to 4, shouldn't the loop stop when (novertex=4)???
回复

使用道具 举报

0

主题

127

帖子

130

银币

限制会员

铜币
-2
发表于 2022-7-6 12:02:15 | 显示全部楼层
 
Yes,
 
The While loop stops when
(
 
BUT, on the last run through, when you are dealing with the last vertex ; you use this
(nth (+ ENTCNT 1) VERTEXLISTX)
 
effectively asking for the index AFTER the last one ...
回复

使用道具 举报

0

主题

127

帖子

130

银币

限制会员

铜币
-2
发表于 2022-7-6 12:10:34 | 显示全部楼层
Just for comparison, perhaps have a look at something like this
  1. (defun c:doit (/ sh ll ur) (vl-load-com) (setq SH (ssget '((0 . "LWPOLYLINE")))) (vla-getboundingbox   (vlax-ename->vla-object (ssname SH 0))   'll   'ur ) (setq ll (vlax-safearray->list ll)       ur (vlax-safearray->list ur) ) (alert (strcat          "LowerLeft : "          (vl-prin1-to-string ll)          "\nUpperRight : "          (vl-prin1-to-string ur)        ) )
回复

使用道具 举报

21

主题

80

帖子

59

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-6 12:23:44 | 显示全部楼层
OK.
I'm so thankful about your description and altenative code. It is perfect and has a few arguman vs. my code.
It is so faster by using activex functions.
I hope that i learn this method as soon as possible.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-4 05:40 , Processed in 0.328442 second(s), 67 queries .

© 2020-2025 乐筑天下

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