看看这个函数:
- (defun Get(pt ptlist / ent entv ent2 entv2 n i j ptv ptx pt2x pts a b)
- ;(setq ent (car (entsel)))
- (command "_.line" '(0 0) '(1 1) "")
- (setq ent (entlast))
- (command "_.line" '(0 0) '(1 1) "")
- (setq ent2 (entlast))
-
- (setq entv (vlax-ename->vla-object ent))
- (setq entv2 (vlax-ename->vla-object ent2))
- (setq i 0)
- (setq ptv (vlax-3d-point pt))
- (setq n (length ptlist))
- (while (< i n)
- (setq ptx (nth i ptlist))
- (vla-put-startpoint entv (vlax-3d-point ptx))
- (vla-put-startpoint entv2 ptv)
- (setq j (1+ i))
- (while (< j n)
- (setq pt2x (nth j ptlist))
- (vla-put-endpoint entv (vlax-3d-point pt2x))
- (vla-put-endpoint entv2 (vlax-3d-point pt2x))
- (setq a (vla-get-delta entv))
- (setq a (vlax-safearray->list (vlax-variant-value a)))
- (setq b (vla-get-delta entv2))
- (setq b (vlax-safearray->list (vlax-variant-value b)))
- (if (and (= (car a) 0) (= (cadr a) 0) (= (car b) 0) (= (cadr b) 0))
- (progn (setq pts (list ptx pt2x)) (setq i n j n))
- (progn
- (if (and
- (/= (+ (car a) (cadr a)) 0)
- (/= (+ (car b) (cadr b)) 0)
- (= (/ (caddr a) (sqrt (+ (* (car a) (car a)) (* (cadr a) (cadr a)))))
- (/ (caddr b) (sqrt (+ (* (car b) (car b)) (* (cadr b) (cadr b)))))
- )
- )
- (if (and (/= (car a) 0) (/= (car b) 0)
- (= (/ (cadr a) (car a)) (/ (cadr b) (car b)))
- )
- (progn (setq pts (list ptx pt2x)) (setq i n j n))
- (if (and (= (car a) 0) (= (car b) 0))
- (progn (setq pts (list ptx pt2x)) (setq i n j n))
- )
- );if
- );if
- );progn
- );if
- (setq j (1+ j))
- );while
- (setq i (1+ i))
- );while
- (entdel ent)
- (entdel ent2)
- pts
- )
|