给点帮助
;;; ;;;选择并计算曲线参数函数DimSelqx ;;;返回值:曲线参数(alfa[弧度] R[mm]) ;;; (defun DimSelqx( / wh ss ssLen i alfa R Ename vdata N p1 p2 bulge alfai XL Ri)
(setq wh 1 ss nil) (while (and (= wh 1) (setq ss (ssget '((0 . "LWPOLYLINE")))) ) (setq ssLen (sslength ss)) (setq i 0 wh 0 R 0 alfa 0) (while (and (= wh 0) (< i ssLen)) (setq Ename (ssname ss i)) (setq vdata (entget Ename)) (setq N (length vdata)) (setq p1 (cdr (nth (- N 9) vdata)) ;第一个顶点 p2 (cdr (nth (- N 5) vdata))) ;第二个顶点 (setq bulge (cdr (nth (- N 6) vdata))) ;第一个顶点凸度 (if (/= bulge 0) (progn (setq alfai (* 4 (atan (abs bulge))) XL (distance p1 p2) Ri (ccfix (/ (/ XL 2) (sin (/ alfai 2))) 0)) (if (and (/= R Ri) (/= i 0)) (progn (redraw Ename 3) (alert "曲线半径不同,请重新选择!") (redraw Ename 4) (setq wh 1) ) (setq alfa (+ alfai alfa) R Ri) ) ) (progn (redraw Ename 3) (alert "虚显的巷道是直线,请重新选择!") (redraw Ename 4) (setq wh 1) ) ) (setq i (1+ i)) ) ) (if (not ss) (exit) ) (setq ss nil) (list alfa R)
);End DimSelqx |