autolisp

Autolisp:利用AuoCAD之Lisp编程案例之智能加工齿轮的演示程序

目录

实现结果

实现代码

实现结果

实现代码

(defun dlg1();初始化对话一

(set_tile "_m" "5");模数列表第6项

(set_tile "_z" "20");齿数20

(set_tile "_alf" "2");压力角第3项

(set_tile "s_z" "20");齿数滑动条

(set_tile "cut" "2");齿廓列表第3项

(action_tile "_m" "(setq msh_ $value)")

(action_tile "s_z" "(fsz)")

(action_tile "_z" "(fz)")

(action_tile "s_x" "(fs_x)")

(action_tile "_x" "(f_x)")

(action_tile "_alf" "(setq ylj_ $value)")

(action_tile "prec0" "(setq qxcsh 5)")

(action_tile "prec1" "(setq qxcsh 10)")

(action_tile "prec2" "(setq qxcsh 15)")

(action_tile "accept" "(getd)(done_dialog 1)")

(action_tile "cancel" "(done_dialog 0)")

(action_tile "help" "(dlg3)")

)

;定义获取控件当前数据的函数

(defun getd()

(setq msh_ (get_tile "_m"))

(setq msh (atof(nth (atoi msh_) m_lst)));模数

(setq ylj_ (get_tile "_alf"))

(setq ylj (atof(nth (atoi ylj_) alf_lst)));压力角

(setq bwxsh(atof(get_tile "_x")));变位系数

(setq chsh(atoi(get_tile "_z")));齿数

)

;定义齿数编辑框的活动的函数

(defun fz(/ gz)

(setq gz(atoi $value))

(if (or (< gz 9)(> gz 100))

(progn

(set_tile $key (get_tile "s_z"))

(setq chsh(atoi $value))

)

(progn

(set_tile "s_z" (itoa gz))

(setq chsh gz)

)

)

)

;定义齿数滑动条的活动的函数

(defun fsz()

(set_tile "_z" $value)

(setq chsh (atoi $value))

)

;定义变位系数滑动条的活动的函数

(defun fs_x(/ xx)

(setq xx (atof $value))

(setq bwxsh(* 0.01 xx))

(setq xx(rtos bwxsh 2 2))

(set_tile "_x" xx)

)

;定义变位系数编辑框的活动的函数

(defun f_x(/ xx )

(setq xx(atof $value))

(if (or (< xx -1)(> xx 1))

(progn

(setq xx (get_tile "s_x"))

(setq xx(atof xx))

(setq bwxsh(* 0.01 xx))

(set_tile $key (rtos bwxsh 2 2))

)

(progn

(setq bwxsh xx)

(setq xx(* 100 xx))

(set_tile "s_x" (itoa xx))

)))

;定义齿轮加工的函数

(defun makegear()

(setq chlzhx '(0 0));齿轮中心

(setq ylj (* pi (/ ylj 180.0)));度转换为弧度

(setq chgao (* msh (+ chdgaoxsh bwxsh)));齿高=1

(setq fdybj (* 0.5 (* msh chsh)));分度圆半径

(setq dybj (+ fdybj (* msh (+ chdgaoxsh bwxsh))));齿顶圆半径

(setq kbj (* 0.25 dybj));轮孔半径

(setq lm1 (list (- (car chlzhx) (* 2 dybj)) (+ (last chlzhx) dybj)));图纸界限的左下角

(setq lm2 (list (+ (* 5 msh) (car chlzhx) dybj) (- (last chlzhx) (+ 10.0 (* chdjx msh)) dybj)));图纸界限的右上角

(command "zoom" lm1 lm2)

(setq jybj (+ fdybj (* bwxsh msh)));节圆半径=分度圆半径+变位量

(setq temy1 (* msh (+ chdjx chdgaoxsh)));齿顶高1+齿顶间隙0.25

(setq chtgen (+ jybj temy1));齿轮中心到齿条根部的距离

(setq chtdi (+ chtgen 3.0));齿轮中心到齿条底根部的距离

(setq chtdi (- (cadr chlzhx) chtdi));齿条下底的y

(setq chtzuo (- (car chlzhx) (* 2 jybj)));齿条左边x

(setq p01 (list chtzuo chtdi))

(setq chw (* pi msh));周节

(setq chtgeny(+ chtdi 3.0));齿条根y

(setq p0 (list chtzuo chtgeny))

(setq chh (* 2.0 temy1));齿条全齿高

(setq chb (/ (* chh (sin ylj)) (cos ylj)))

(setq cha (* 0.25 (- chw (* 2 chb))))

(setq chnu(* 0.5 chsh));齿条的齿数

(setq chnum 0.0)

(command "color" "green")

(setq chtemp p0)

(command "pline" p01 p0 )

(while(< chnum chnu);绘制齿条轮廓线

(setq chnum (1+ chnum))

(command (setq p1 (list (+ cha (car p0)) (cadr p0))))

(command (setq p2 (list (+ chb (car p1)) (+ chh (cadr p1)))))

(command (setq p3 (list (+ (* 2.0 cha) (car p2)) (cadr p2))))

(command (setq p4 (list (+ chb (car p3)) (- (cadr p3) chh))))

(command (setq p5 (list (+ cha (car p4)) (cadr p4))))

(setq p0 p5)

)

(setq p02 (list (+ chtzuo (* chnum chw)) chtdi))

(command p02 p01 "c");齿条轮廓线绘制完毕

(setq e1(entlast));获取齿条的图元名

(command "region" e1 "");将齿条转换为面域

(setq tiao(entlast));获取转换为面域的齿条的图元名

(command "color" "white")

(command "circle" chlzhx dybj);绘制齿顶圆

(setq c1(entlast));获取齿顶圆的图元名

(command "region" c1 "");将齿顶圆转换为面域

(setq c1(entlast));获取转换为面域的齿顶圆的图元名

(command "circle" chlzhx kbj);绘制轮孔圆

(setq c2(entlast));获取轮孔圆的图元名

(command "region" c2 "");将轮孔圆转换为面域

(setq c2(entlast));获取转换为面域的轮孔圆的图元名

(command "subtract" c1 "" c2 "");齿顶圆的面域减去轮孔圆的面域

(setq lun(entlast));获取齿轮毛坯的图元名

(setq dphi(/ 360.0 (* chsh qxcsh)));齿轮毛坯每次旋转角度

(setq chtydjl (/ chw qxcsh));齿条每次移动距离

(setq shjqxcsh 0);实际切削次数

(setq ydjl 0.0);累计移动距离

(while (<= shjqxcsh (* qxcsh chsh))

(setq ydjl (+ ydjl chtydjl))

(setq dx chtydjl);齿条移动距离

(if (>= ydjl chw)

(progn;ydjl大于等于周节chw

(setq ydjl 0.0)

(setq dx (* (- 1 qxcsh) chtydjl));齿条退回一个周节

)

)

(command "copy" tiao "" '(0 0) '(0 0));原地复制齿条

(setq tiao1(entlast))

(command "subtract" lun "" tiao1 "");齿轮毛坯减去齿条

(command "rotate" lun "" chlzhx dphi);齿轮毛坯旋转dphi

(command "move" tiao "" '(0.0 0.0) (list dx 0.0));齿条移动dx

(setq shjqxcsh (1+ shjqxcsh))

)

)

;定义齿轮参数显示的函数

(defun showdata()

(if (not (new_dialog "gear_list" id))(exit))

(setq x1(dimx_tile "image2")) ;设置x1为图象宽

(setq y1(dimy_tile "image2")) ;设置y1为图象高

(start_image "image2") ;开始建立图象

(slide_image -10 -10 (+ x1 20) y1 "d:/example/sld/13-2-21") ;-10 -10 (+ x1 20) y1

(end_image) ;图象建立毕

(set_tile "t1" (strcat "模数m: " (rtos msh 2 2)))

(set_tile "t2" (strcat "齿数z: " (itoa chsh)))

(setq ylj(* 180 (/ ylj pi)))

(set_tile "t3" (strcat "压力角a: " (rtos ylj 2 2) "?" ));jlj0

(set_tile "t4" (strcat "变位系数x: " (rtos bwxsh 2 2)))

(set_tile "t5" (strcat "分度圆直径d: " (rtos (* 2 fdybj) 2 2)))

(set_tile "t6" (strcat "齿顶圆直径da: " (rtos (* 2 dybj) 2 2)))

(set_tile "t7" (strcat "齿根圆直径df: " (rtos (* 2 (- dybj (* 2.25 msh))) 2 2)))

(action_tile "accept" "(done_dialog 1)")

(action_tile "xwj" "(done_dialog 2)")

(if (> (start_dialog) 1)(fwfile))

)

;定义将齿轮参数写到指定文件的函数

(defun fwfile()

(setq fname(getfiled "输入存放齿轮参数的文件" "" "txt" 1))

(setq fp(open fname "w"))

(write-line (strcat "模数m: " (rtos msh 2 2)) fp)

(write-line (strcat "齿数z: " (itoa chsh))fp)

(write-line (strcat "压力角a: " (rtos ylj 2 2) "?" )fp)

(write-line (strcat "变位系数x: " (rtos bwxsh 2 2))fp)

(write-line (strcat "分度圆直径d: " (rtos (* 2 fdybj) 2 2))fp)

(write-line (strcat "齿顶圆直径da: " (rtos (* 2 dybj) 2 2))fp);

(write-line (strcat "齿根圆直径df: " (rtos (* 2 (- dybj (* 2.25 msh))) 2 2))fp)

(close fp)

)

; 主函数

(defun c:niu( / bwxsh c1 c2 cha chb chdgaoxsh chdjx chgao chh chnu chnum chsh chlzhx chtdi chtemp chtgen chtgeny chtydjl chtzuo chw dphi dx dybj e1 fdybj fname fp jybj kbj lm1 lm2 lun msh msh_ p0 p01 p02 p1 p2 p3 p4 p5 qxcsh shjqxcsh temy1 tiao tiao1 x0 x1 y0 y1 ydjl ylj ylj_ zhxx zhxy)

(setvar "cmdecho" 0)

(setvar "blipmode" 0)

(setvar "osmode" 0)

(setq chdgaoxsh 1.0);齿高系数

(setq chdjx 0.25);齿间隙

(setq qxcsh 15)

(setq id(load_dialog "d:/example/dcl/13-2")) ;装入对话框文件

(if (< id 0)(exit))

(setq what 3)

(while (> what 1)

(if (not (new_dialog "mgear" id))(exit))

(setq x1(dimx_tile "image1")) ;设置x1为图象宽

(setq y1(dimy_tile "image1")) ;设置y1为图象高

(start_image "image1") ;开始处理图象

(slide_image -10 -25 (+ x1 100) y1 "d:/example/sld/13-2-1") ;-10 -25 (+ x1 20) y1

(end_image) ;图象处理完毕

(setq m_lst(list "1" "1.25" "1.5" "2" "2.5" "3" "4" "5" "6" "8" "10"))

(start_list "_m") ;开始处理模数列表

(mapcar 'add_list m_lst)

(end_list);模数列表处理完毕

(setq alf_lst(list "14.5" "15" "20" "22.5" "25"))

(start_list "_alf");开始处理压力角列表

(mapcar 'add_list alf_lst)

(end_list);压力角列表处理完毕

(dlg1) ;初始化对话框一

(if (/= what 2) (setq what (start_dialog)))

) ;while结束

(if (= what 1)

(progn

(makegear);调用加工齿轮的函数

(showdata);调用显示齿轮参数的函数

)

)

(unload_dialog id);卸载对话框文件

)

相关阅读

新房装修好,一切东西都要换新啦,家里那台老旧泛黄的噪音空调终于“光荣下岗”,立即入手心仪已久的智米变频空调!这款智

距离2018年结束只剩下7天了,一到年终岁末,回顾、盘点就成为最常出现的词语。本文也不例外,纵观这一年,你会发现今年的营销圈格外热闹,

快播看起来不可能再重获新生,它曾是中国最好、用户规模最大的视频播放软件,但无法做到大而不倒。在所有的转型机遇面前,它一次次错失

若小米直达服务能成为现象级的产品时,手机能随时使用到的应用数量将趋于无限。以下为本文目录:一、 直达服务的背景1、互联网发展趋

简介

模拟退火算法(Simulate Anneal,SA)是一种通用概率演算法,用来在一个大的搜寻空间内找寻命题的最优解。其思想借鉴于固体的退火

lisp编程 滑动轴承的auto_「autolisp」Autolisp:利用AuoCAD之Lisp编程案例之智能加工齿轮的演示程序 - seo实验室...相关推荐

  1. 【转载】:Autolisp:利用AuoCAD之Lisp编程案例之智能加工齿轮的演示程序-----一个处女座程序猿

    利用AuoCAD之Lisp编程案例之智能加工齿轮的演示程序 (defun dlg1();初始化对话一 (set_tile "_m" "5");模数列表第6项 ( ...

  2. python删除空白没有显示_「whitespace」python学习笔记:whitespace(空白符)及其判断、删除方法 - seo实验室...

    whitespace 一.string模块里的常量whitespace(string.whitespac)包含6个字符: ASCII码 字符表示 显示 描述 9 \t 无 HT,horizontal ...

  3. java的actionlistener_「actionlistener」Java——事件处理机制监听者基础(一)动作监听ActionListener - seo实验室...

    actionlistener 介绍: actionlistener是一个接口,ActionEvent通常在点击一个按钮或双击某个列表项或选中某个菜单时发生. 如何设置监听: 对监听者添加ActionL ...

  4. java 过滤器执行图_「filterchain」java 过滤器Filter中chain.doFilter()之前和之后代码的执行顺序 - seo实验室...

    filterchain 过滤器拦截到请求之后,首先是执行doFilter()方法中chain.doFilter()之前的代码,然后放弃权限给下一个过滤器或者serverlet等等,最后才执行chain ...

  5. mysql pk uk_「fk」SQL中PK、UK、DF、CK、FK的意思 - seo实验室

    fk PK 主键 constraint primary key UK 唯一约束 DF 约束默认 constrint default for CK 检查约束 constraint check() FK ...

  6. Autolisp:利用AuoCAD之Lisp编程案例之自动智能绘制枫叶玫瑰

    Autolisp:利用AuoCAD之Lisp编程案例之自动智能绘制枫叶玫瑰 目录 输出结果 实现代码 输出结果 实现代码 ;风玫瑰程序: GXFMG.LSP 1989.1. (defun dbh(a) ...

  7. Autolisp:利用AuoCAD之Lisp编程案例之自动智能获取所选对象的面积并标注在指定位置

    Autolisp:利用AuoCAD之Lisp编程案例之自动智能获取所选对象的面积并标注在指定位置 目录 输出结果 实现代码 输出结果 实现代码 ;; write area value of a clo ...

  8. lisp编程 滑动轴承的auto_基于Visual Lisp的滑动轴承设计

    龙源期刊网 http://www.qikan.com.cn 基于 Visual Lisp 的滑动轴承设计 作者:姚敏茹 成阔 来源:<科技创新导报> 2011 年第 26 期 摘 要 : ...

  9. Ps 初学者教程「42」如何利用渐变工具实现平滑过渡?

    欢迎观看 Photoshop 教程,小编带大家了解如何利用渐变工具实现平滑过渡. 在 Photoshop 中合成图片时,要获得无缝渐变的混合效果,最好的方法就是图层蒙版和渐变工具搭配使用.在本教程中, ...

  10. 筑算高程点提取插件_「教程」原来利用高程数据点建立地形模型,只需要一个键...

    ©版权申明 本文由大地老周原创,如有转载请联系我们 各位同学经过前几期的学习,有没有对地形模型这一块的知识有更深的理解,和自己的解读呢~ 小编休息了几期,好好沉淀了一番,精心为大家准备了第四期的课程 ...

最新文章

  1. Java中文编码小结
  2. 解开一个困扰自己多时的小问题
  3. 阿里云ONS而微软Azure Service Bus体系结构和功能比较
  4. 架构设计:生产者/消费者模式 第3页:队列缓冲区
  5. python爬虫之美剧排行榜爬取(加浏览器伪装,代理,异常处理)
  6. .NET 简单的smtp协议发邮件
  7. 计算机大赛软件应用与开发,我院学生在2019年中国大学生计算机设计大赛“软件应用与开发”决赛中荣获佳绩...
  8. LeetCode 106. 从中序与后序遍历序列构造二叉树(递归)
  9. 真正的mybatiesPlus一键生成模板(根据对象增删改查分页的controller完善)详
  10. MySQL的replace()函数
  11. webpack 使用教程
  12. DevOps使用教程 华为云(5)迭代计划 进度管理
  13. 宽带路由器-mac地址克隆
  14. ddm模型公式_绝对估值法DDM、DCF、RNAV模型简介
  15. 现代化智能一体化机柜
  16. 多源异构数据库实时同步解决方案
  17. fastadmin 表格文字实现换行
  18. C、C++中出现nan、inf原因
  19. Angular NgModule
  20. 环境变量和模式(Vite)

热门文章

  1. 淘宝6.18叠猫猫赚猫币自动生成
  2. Linux的命名空间
  3. 了解了广告行业利益相关方,横扫一切商业模式
  4. 我的无线路由器是红色的——N倍速的快感,初探Openwrt系统无线路由器
  5. Python爬虫实战—笔趣看小说网
  6. 性质:自反、反自反、对称、反对称、传递、互斥
  7. 计算机笔记本硬盘,笔记本取证之--笔记本硬盘拆卸
  8. Roman to Integer:转换罗马数字到阿拉伯数字
  9. 华为手机自带浏览器的显示问题
  10. 华三服务器bios修改兼容模式,bios怎么设置兼容模式