螺栓二次开发程序

上传人:kms****20 文档编号:40467289 上传时间:2018-05-26 格式:DOC 页数:10 大小:44.50KB
返回 下载 相关 举报
螺栓二次开发程序_第1页
第1页 / 共10页
螺栓二次开发程序_第2页
第2页 / 共10页
螺栓二次开发程序_第3页
第3页 / 共10页
螺栓二次开发程序_第4页
第4页 / 共10页
螺栓二次开发程序_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《螺栓二次开发程序》由会员分享,可在线阅读,更多相关《螺栓二次开发程序(10页珍藏版)》请在金锄头文库上搜索。

1、螺栓二次开发程序螺栓二次开发程序(defun errMsg (s)(if (/= s “function cancelled“) (princ (strcat “Error: “ s); 当命令执行时出现错误(setvar “cmdecho“ ocmdold) ; 例如用户按下了 CTRL + C(setvar “osmode“ osmold)(setq *error* olderr) ; 恢复旧的错误处理(princ)(defun c:3Dthread (/ radouter threadpitch threadlength threadangle ptStart innerdiafacto

2、r 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 6

3、H (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) (setq h6 (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) (setq g6 (list -0.005 -0.008 -0.0095 -0.0115 -0.0135 -0.017 -0.0195 -0.023 -0.0265 -0.0295 -0.

4、033 -0.036 -0.0515) (setq osmold (getvar “osmode“) ; 保存调用前的 osmode 系统变量值(setq ocmdold (getvar “cmdecho“) ; 保存调用前的 cmdecho 系统变量值(setvar “osmode“ 0) ; 关闭对象捕捉 (setvar “cmdecho“ 0) ; 关闭命令的回显(setq innerdiafactor 1.5) ; 设置内径系数(initget 7) ; radmid 必须非零、非空、非负(setq radmid (getdist “公制外径: “)(initget 7) ; thre

5、adpitch 必须非零、非空、非负(setq threadpitch (getreal “螺距: “)(initget 1) ; ptStart 必须非空(setq ptStart (getpoint “起始点: “)(initget 3) ; threadlength 必须非零、非空、非负(setq threadlength (getdist “螺纹总长(Y 方向): “); 对公制外径添加公差(if (= threadpitch 0.35) (setq radmid (+ radmid (nth order 6H)(setq h (* 0.866025 threadpitch) ; 计算

6、齿高(setq radouter (+ radmid (/ h 4) ; 计算外径(setq radinner (- radouter (* h innerdiafactor) ; 计算内径(setq threadangle (+ 30 0) ; 计算齿顶角(auxithread radouter radmid radinner threadpitch threadlength threadangle ptStart) ; 调用绘制三维螺纹的子函数(princ “三维螺纹创建完成“)(setvar “osmode“ osmold) ; 恢复调用前的 osmode 系统变量值(setvar “c

7、mdecho“ ocmdold) ; 恢复调用前的 cmdecho 系统变量值(princ)(defun auxithread (radouter radmid radinner threadpitch threadlength threadangle ptStart / ttal pt1z ang pt1apt1az pt3a pt1b pt1bz pt3b pttmp1 pttmp2 pttmp3 pttmp4 pttmp5 pttmp6 pttmp7 pttmp8 pttmp9 pttmp10 pttmp11 pttmp12 tstmp startcone endcone);(comma

8、nd “undo“ “begin“) ; 开始 undo 步骤(setq ttal (+ (fix (/ (abs threadlength) threadpitch) 3)pttmp1 (list (- (car ptStart) (/ radouter 2.0) (cadr ptStart) (caddr ptStart)pt1z (list (- (car ptStart) (/ radouter 2.0) (cadr ptStart) (+ (caddr pttmp1) 1.0)pttmp2 (polar pttmp1 (/ (* threadangle pi) 180.0) 1)pt

9、tmp3 (list (+ (car pttmp1) radouter) (+ (cadr pttmp1) (/ threadpitch 2.0) (caddr ptStart)ang (angle pttmp1 pttmp3)pt1a (polar pttmp1 (+ ang (/ pi 2.0) threadpitch)pt1az (list (car pt1a) (cadr pt1a) (+ (caddr pt1a) 1.0)pt3a (polar pt1a ang radouter)pt1b (polar pttmp1 (- ang (/ pi 2.0) threadpitch)pt1

10、bz (list (car pt1b) (cadr pt1b) (+ (caddr pt1b) 1.0)pt3b (polar pt1b ang radouter)pttmp4 (polar pttmp3 (/ (* (- 180 threadangle) pi) 180.0) 1)pttmp5 (inters pttmp1 pttmp2 pttmp3 pttmp4 nil)pttmp6 (list (car pttmp5) (cadr ptStart) (caddr ptStart)pttmp7 (polar pttmp1 (/ (* (- 360 threadangle) pi) 180.

11、0) 1)pttmp8 (polar pttmp3 (/ (* (+ 180 threadangle) pi) 180.0) 1)pttmp9 (inters pttmp1 pttmp7 pttmp3 pttmp8 nil)pttmp10 (list (car pttmp9) (cadr pttmp3) (caddr pttmp3)pttmp11 (polar ptStart (/ pi 2.0) threadpitch)pttmp12 (polar pttmp11 (/ pi 2.0) (abs threadlength);-; 绘制两个倒置的并偏移 1/2 螺距的圆锥; 这两个圆锥都以中剖

12、面剖分; 进行并集运算;-(SETQ startcone “order“)(SETQ endcone “Y“)(command “zoom“ “w“ (list (car pt1a) (+ (cadr pt1a) (abs threadlength) (caddr pt1a) pt3b)(princ “正在绘制三维螺纹,请等待“)(command “pline“ pttmp1 pttmp5 pttmp6 “c“)(command “revolve“ “l“ “ pttmp5 pttmp6 “)(command “slice“ “l“ “ pttmp1 pttmp3 pt1z pttmp5)(command “slice“ “l“ “ pt1a pt3a pt1az pttmp3)(setq tstmp (ssadd (entlast)(command “pline“ pttmp3 pttmp9 pttmp10 “c“)(command “revolve“ “l“ “ pttmp9 pttmp10 “)(command “

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号