3DTANHUANG三维弹簧.lsp
资源名称:cadlisp1.rar [点击查看]
上传用户:sd555111
上传日期:2014-05-17
资源大小:31k
文件大小:2k
源码类别:
CAD
开发平台:
MathCAD
- (defun c:3dtanhuang(/)
- (setq p1(getpoint "请指定螺旋线基点:"))
- (setq r(getreal "请输入弹簧平均半径:"))
- (setq d0(getreal "请输入弹簧丝直径:"))
- (setq disp(getreal "请输入弹簧节距:"))
- (setq n0(getint "请输入弹簧工作圈数:"))
- (setq n(getint "请输入每圈细化段数(16/20/24/28/32/36/50/100):"))
- (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" "o" 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")
- )