(defun c:tanhuang(/) (setq p1 (getpoint "请指定螺旋线基点:")) (setq r (getreal "请输入弹簧平均半径:")) (setq d0 (getreal "请输入弹簧丝直径:")) (setq disp (getreal "请输入弹簧节距:")) (setq n0 (getint "请输入弹簧工作圈数:")) (setq n (getint "请输入每圈细化段数 (32/36/40/44/48/52/56/60) :")) (setq n1 (* 1.25 n)) ;支撑圈细化段数 (setq n1 (fix n1)) (setq n2 (* n0 n)) ;工作圈细化段数 (setq delta (/ (* 2.0 pi) n)) ;单位转角 (setq j (/ disp n)) ;工作圈轴向位移量 (setq j0 (/ d0 n)) ;支撑圈轴向位移量 (setq bb (caddr p1)) (setq ang 0) (setq jj 0) (command "ucs" "n" p1) (setq pt1 (list r 0 0)) (command "3dpoly" pt1) (repeat n1 ;绘制下支撑圈 (setq jj (+ jj 1)) (setq ang (+ delta ang)) (setq pt (list (* r (cos ang)) (* r (sin ang )) (* j0 jj))) (command pt) ) (setq p2 (list 0 0 (* j0 jj))) (setq g1 (* j0 jj)) ;下支撑圈高度 (setq jj 0) (repeat n2 ;绘制工作圈 (setq jj (+ jj 1)) (setq ang (+ delta ang)) (setq pt (list (* r (cos ang )) (* r (sin ang)) (+ g1 (* j jj)))) (command pt) ) (setq p3 (list 0 0 (* j jj))) (setq g2 (* j jj)) ;工作圈高度 (setq jj 0) (repeat n1 ;绘制上支撑圈 (setq jj (+ jj 1)) (setq ang (+ delta ang)) (setq pt (list (* r (cos ang)) (* r (sin ang)) (+ g1 g2 (* j0 jj)))) (command pt) ) (setq g3 (* j0 jj)) ;上支撑圈高度 (command "") (setq e1 (entlast )) (command "ucs" "x" "") (command "circle" pt1 (/ d0 2)) (setq e2 (entlast)) (command "extrude" e2 "" "p" e1) ;拉伸弹簧 (setq e3 (entlast)) (setq pt2 (list r (/ d0 4) 0)) (setq py (+ g1 g2 g3 (- 0 (/ d0 4)))) (setq pt3 (list (- 0 r) py 0)) (command "slice" e3 "" "zx" pt2 pt3) ;磨平端部支撑面 (command "slice" e3 "" "zx" pt3 pt2) (command "ucs" "w") )
|