一、齿轮轮齿渐开渐开线
(defun c:gear(/)
(
setq
p0 (getpoint"输入齿轮中心p0: ")
m (getreal"输入齿轮模数M: ")
z (getint"输入齿轮齿数Z: ")
ha 1
c 0.25
a (/ pi 9)
ra(/ (* (+ z (+ ha ha)) m) 2)
rf(/ (* (- z (+ (+ ha ha) c)) m) 2)
r(/ ( * m z) 2)
rb ( * r (cos a))
ri rb
ang 0
g (polar p0 ang rb)
)
(command "circle" p0 ra)
(command "circle" p0 rf)
(command "circle" p0 r)
(command "line" g)
(while (< ri ra)
(setq
ang ( + ang(/ pi 360))
ri ( / rb (cos ang))
cta ( - (/ (sin ang) (cos ang)) ang)
g(polar p0 cta ri)
)
(command g)
)
(command )
)
二、螺旋源程序
(defun errMsg (s)
(if (/= s "function cancelled") (princ (strcat "\nError: " s)))
; 当命令执行时出现错误
(setvar "cmdecho" ocmdold) ; 例如用户按下了CTRL + C
(setvar "osmode" osmold)
(setq *error* olderr) ; 恢复旧的错误处理
(princ)
)
(defun c:3Dthread (/ radouter threadpitch threadlength threadangle
ptStart innerdiafactor radmid radinner ocmdold osmold 4H 5H 6H h6 g6)
;-------------------------------------------------------------------
; 获取公制外径大小、螺距总长
; 然后计算一系列几何点
; 并且关闭对象捕捉、命令回显
;-------------------------------------------------------------------
(setq 4H (list 0.0015 0.002 0.002 0.0025 0.003 0.0035 0.004 0.005 0.006 0.007 0.008 0.009 0.010))
(setq 5H (list 0.002 0.0025 0.003 0.004 0.0045 0.0055 0.0065 0.0075 0.009 0.010 0.0115 0.0125 0.0135))
(setq 6H (list 0.003 0.004 0.0045 0.0055 0.0065 0.008 0.0095 0.011 0.0125 0.0145 0.016 0.018 0.020))