乐筑天下

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

[编程交流] 循环创建的对象列表

[复制链接]

43

主题

136

帖子

92

银币

后起之秀

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

铜币
217
发表于 2022-7-6 07:25:52 | 显示全部楼层 |阅读模式
大家好,
 
请帮忙!
 
我做了一个例程,但夹在两者之间,因为它直到最后才创建对象。下面是我卡住的部分代码。
 
  1. ;;-----------------=={ Group by Number }==--------------------;;
  2. ;;                                                            ;;
  3. ;;  Groups a list into a list of lists, each of length 'n'    ;;
  4. ;;------------------------------------------------------------;;
  5. ;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
  6. ;;------------------------------------------------------------;;
  7. ;;  Arguments:                                                ;;
  8. ;;  l - List to process                                       ;;
  9. ;;  n - Number of elements by which to group the list         ;;
  10. ;;------------------------------------------------------------;;
  11. ;;  Returns:  List of lists, each of length 'n'               ;;
  12. ;;------------------------------------------------------------;;
  13. (defun LM:GroupByNum (l n / r)
  14.    (if        l
  15.      (cons
  16. (reverse (repeat n
  17.            (setq r (cons (car l) r)
  18.                  l (cdr l)
  19.            )
  20.            r
  21.          )
  22. )
  23. (LM:GroupByNum l n)
  24.      )
  25.    )
  26. )
  27. ;;-----------------=={ Get Intersections }==------------------;;
  28. ;;                                                            ;;
  29. ;;  Returns a list of all points of intersection between      ;;
  30. ;;  two objects                                               ;;
  31. ;;------------------------------------------------------------;;
  32. ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  33. ;;------------------------------------------------------------;;
  34. ;;  Arguments:                                                ;;
  35. ;;  obj1, obj2 - VLA-Objects                                  ;;
  36. ;;------------------------------------------------------------;;
  37. ;;  Returns:  List of intersection points, or nil             ;;
  38. ;;------------------------------------------------------------;;
  39. (defun LM:GetIntersections (obj1 obj2)
  40.    (LM:GroupByNum
  41.      (vlax-invoke obj1 'IntersectWith obj2 acExtendnone)
  42.      3
  43.    )
  44. )
  45. (setq Kpr (car (entsel "\nSelect Polyline:")))
  46. (setq cntr 1
  47. ctr 0
  48. cnr 2)
  49. (setq Panl (list (entlast)));saves last drawn rectangle
  50. (repeat (1+ (fix (/ (vla-get-length (vlax-ename->vla-object Kpr)) 700)))
  51.    [color="blue"](setq InterCheck (LM:GetIntersections (vlax-ename->vla-object Kpr) (vlax-ename->vla-object (nth ctr Panl))));check intersection between rec and Pline[/color]
  52.    (setq FirstVert (nth 0 InterCheck))
  53. (if (not (nth cntr Coorlist));coorlist is the list of LWpolyline vertices list
  54.    (setq SecondVert (nth (- cnr cntr) Coorlist))
  55.    (setq SecondVert (nth cntr Coorlist)))
  56.    (setq FSAng (rtd (angle FirstVert SecondVert)); rtd is radian to degree
  57.   FScounterAng (angle SecondVert FirstVert)
  58.   StartP (polar FirstVert FScounterAng 100))
  59.    (MakePanel FirstVert StartP Plength Pwidth FSAng); MakePanel is a fundtion to create Rectangles
  60. [color="blue"](setq Panl (cons (entlast) Panl))[/color]
  61. (setq cntr (1+ cntr)
  62. ctr (1+ ctr)
  63. cnr (1+ cnr)))

 
当重复函数循环时,突出显示的代码就是我卡住的地方,但我不明白为什么?
任何帮助都是值得赞赏的。
 
谢谢和问候
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-10 04:46 , Processed in 0.544232 second(s), 54 queries .

© 2020-2025 乐筑天下

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