本帖最后由 Gu_xl 于 2012-3-26 19:10 编辑
;;等分曲线,返回点坐标
;;参数 Curve = 曲线图元名 p1 = 曲线上第一点 p2 = 曲线上第一点
;; Flag = T 定数等分曲线 nil 定长等分曲线
;; n = 当 Flag = T 时 n 为等分数,当Flag = nil 时 n 为等分长度
;;测试: (DivdeCurve (car(entsel "\n选择曲线:")) (getpoint "\n起点:") (getpoint "\n终点:") nil 15)
- (defun DivdeCurve (CURVE P1 P2 FLAG N / D1 D2 D FUN D0 PTS)
- (setq p1 (vlax-curve-getclosestpointto Curve p1)
- d1 (vlax-curve-getDistAtPoint Curve p1)
- p2 (vlax-curve-getclosestpointto Curve p2)
- d2 (vlax-curve-getDistAtPoint Curve p2)
- )
- (if Flag
- (setq d (/ (- d2 d1) n) )
- (setq d (if (MINUSP (- d2 d1)) (* -1.0 n) n) )
- )
- (if (> d2 d1) (setq Fun '<) (setq Fun '>))
- (setq d0 d1)
- (while (apply fun (list (setq d0 (+ d0 d)) d2))
- (setq pts (cons (vlax-curve-getPointAtDist curve d0) pts))
- )
- (reverse pts)
- )
|