循环创建的对象列表
大家好,请帮忙!
我做了一个例程,但夹在两者之间,因为它直到最后才创建对象。下面是我卡住的部分代码。
;;-----------------=={ Group by Number }==--------------------;;
;; ;;
;;Groups a list into a list of lists, each of length 'n' ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;l - List to process ;;
;;n - Number of elements by which to group the list ;;
;;------------------------------------------------------------;;
;;Returns:List of lists, each of length 'n' ;;
;;------------------------------------------------------------;;
(defun LM:GroupByNum (l n / r)
(if l
(cons
(reverse (repeat n
(setq r (cons (car l) r)
l (cdr l)
)
r
)
)
(LM:GroupByNum l n)
)
)
)
;;-----------------=={ Get Intersections }==------------------;;
;; ;;
;;Returns a list of all points of intersection between ;;
;;two objects ;;
;;------------------------------------------------------------;;
;;Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;;
;;------------------------------------------------------------;;
;;Arguments: ;;
;;obj1, obj2 - VLA-Objects ;;
;;------------------------------------------------------------;;
;;Returns:List of intersection points, or nil ;;
;;------------------------------------------------------------;;
(defun LM:GetIntersections (obj1 obj2)
(LM:GroupByNum
(vlax-invoke obj1 'IntersectWith obj2 acExtendnone)
3
)
)
(setq Kpr (car (entsel "\nSelect Polyline:")))
(setq cntr 1
ctr 0
cnr 2)
(setq Panl (list (entlast)));saves last drawn rectangle
(repeat (1+ (fix (/ (vla-get-length (vlax-ename->vla-object Kpr)) 700)))
(setq InterCheck (LM:GetIntersections (vlax-ename->vla-object Kpr) (vlax-ename->vla-object (nth ctr Panl))));check intersection between rec and Pline
(setq FirstVert (nth 0 InterCheck))
(if (not (nth cntr Coorlist));coorlist is the list of LWpolyline vertices list
(setq SecondVert (nth (- cnr cntr) Coorlist))
(setq SecondVert (nth cntr Coorlist)))
(setq FSAng (rtd (angle FirstVert SecondVert)); rtd is radian to degree
FScounterAng (angle SecondVert FirstVert)
StartP (polar FirstVert FScounterAng 100))
(MakePanel FirstVert StartP Plength Pwidth FSAng); MakePanel is a fundtion to create Rectangles
(setq Panl (cons (entlast) Panl))
(setq cntr (1+ cntr)
ctr (1+ ctr)
cnr (1+ cnr)))
当重复函数循环时,突出显示的代码就是我卡住的地方,但我不明白为什么?
任何帮助都是值得赞赏的。
谢谢和问候
页:
[1]