




已阅读5页,还剩12页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Mechanical CAD/CAM螺钉的参数化设计(基于VBA的AutoCAD螺钉二次开发)Parametric Design of screwName: Student No: Student ID: Expecting score: 1. The Object of DesignProgramming for drawing a screw, screw bolt or other graphics by using VLISP, VBA, etc. illustrated in the figure 1-1.Figure 1-1 The design is based on VBA as a tool for screw parameter design. Reference mechanical drawing textbooks, slotted cheese head screws of the partial table as shown below.本次设计是以VBA为工具进行螺钉的参数化设计。参考机械制图课本,开槽圆柱头螺钉的部分表格如下所示。 Table 1 Slotted cheese head screws (from GB/T 65- 2000) mm螺纹规格M4M5M6M8M10b3838383838dk78.5101316k56n22.5t22.4公称长度l54065086010801280l系列5,6,8,10,12,(14),16,20,25,30,35,40,45,50,(55),60,(65),70,(75),80Method: Take p0 for positioning point, according to the table, select the screw diameter D and nominal length of L data, determine the screws of the dk,k,n,t parameters. The screw points identified, wired generation screw CAD diagram, as illustrated in the figure 1-2.思路:取p0点为定位点,根据上表,选择螺钉规格和公称长度l,确定螺钉的dk,k,n,t参数。从而将螺钉的各点确定,连线生成螺钉CAD图。如图1-2所示。Figure 1-2 2. process of programming 1) Open Microsoft Visual Basic editor window shown as figured 2-1, figure 2-2. Figure 2-1 Figure 2-2 2) Edit the VB interface, as illustrated figure 2-3 to figure 2-4. Figure 2-3 Figure 2-4 3) Program, as illustrated figure 2-5 to as illustrated figured 2-7.Figure 2-5 Figure 2-6 Figure 2-7 4) Click Run, as illustrated figure 2-8.Figure 2-8 5) Input the data, as illustrated figure 2-9 to figure 2-10.Figure 2-9 Figure 2-10 6) Press “确定”,then we will get a screw that we expect, as illustrated figure 2-11 to figure 2-13.Figure 2-11 Figure 2-12 Figure 2-13 3. Special attentionWhen you run the program, when selecting screw nominal length of L data is less than the length of thread B numerical value, then screw nominal length L data is equal to the length of thread b values ( in the process of b=38), fault-tolerant procedures are as follows:Dim s As Double If L - b 0 Then s = 0 Else: s = L - bEnd IfHere to enter L=35, run the program, the Auto CAD, drawing the screws for the full thread screw. As shown in the figure.运行程序时,当选择螺钉公称长度L的数据小于螺纹长度b的数值时,此时螺钉公称长度L的数据等于螺纹长度b的数值(在本程序中b=38),容错程序如下: Dim s As Double If L - b 0 Then s = 0 Else: s = L - bEnd If此处输入L=35,运行程序,可知,Auto CAD绘制的螺钉为全螺纹螺钉。如图所示:Figure 3-14. ProgramOption ExplicitPublic i As Integer 声明全局变量Public m As IntegerPrivate Sub ComboBox2_Change() If i = 0 Then Combo2.List(0) = 5 Combo2.List(1) = 6 Combo2.List(2) = 8 Combo2.List(3) = 10 Combo2.List(4) = 12 Combo2.List(5) = 16 Combo2.List(6) = 20 Combo2.List(7) = 25 Combo2.List(4) = 14 Combo2.List(5) = 16 Combo2.List(6) = 20 Combo2.List(7) = 25 Combo2.List(8) = 30 Combo2.List(9) = 35 Combo2.List(10) = 40If i = 1 Then Combo2.List(0) = 6 Combo2.List(1) = 8 Combo2.List(2) = 10 Combo2.List(3) = 12 Combo2.List(4) = 16 Combo2.List(5) = 20 Combo2.List(6) = 25 Combo2.List(7) = 30 Combo2.List(8) = 35 Combo2.List(9) = 40 Combo2.List(10) = 45 Combo2.List(11) = 50ElseIf i = 2 Then Combo2.List(0) = 8 Combo2.List(1) = 10 Combo2.List(2) = 12 Combo2.List(3) = 16 Combo2.List(4) = 20 Combo2.List(5) = 25 Combo2.List(6) = 30 Combo2.List(7) = 35 Combo2.List(8) = 40 Combo2.List(9) = 45 Combo2.List(10) = 50 Combo2.List(11) = 60ElseIf i = 3 Then Combo2.List(0) = 10 Combo2.List(1) = 12 Combo2.List(2) = 16 Combo2.List(3) = 20 Combo2.List(4) = 25 Combo2.List(5) = 30 Combo2.List(6) = 35 Combo2.List(7) = 40 Combo2.List(8) = 45 Combo2.List(9) = 50 Combo2.List(10) = 60 Combo2.List(11) = 70 Combo2.List(12) = 80ElseIf i = 4 Then Combo2.List(0) = 12 Combo2.List(1) = 16 Combo2.List(2) = 20 Combo2.List(3) = 25 Combo2.List(4) = 30 Combo2.List(5) = 35 Combo2.List(6) = 40 Combo2.List(7) = 45 Combo2.List(8) = 50 Combo2.List(9) = 60 Combo2.List(10) = 70 Combo2.List(11) = 80 End IfEnd SubPublic Sub CommandButton2_Click() Unload MeEnd SubPublic Sub ComboBox1_Change() ComboBox1.AddItem M4 ComboBox1.AddItem M5 ComboBox1.AddItem M6 ComboBox1.AddItem M8 ComboBox1.AddItem M10 If ComboBox1.Text = M4 Then i = 0 ElseIf ComboBox1.Text = M5 Then i = 1 ElseIf ComboBox1.Text = M6 Then i = 2 ElseIf ComboBox1.Text = M8 Then i = 3 ElseIf ComboBox1.Text = M10 Then i = 4 End IfEnd SubPublic Sub CommandButton1_Click() Dim d As Double, b As Double, dk As Double, k As Double, n As Double, t As Double 查表获得参数 If i = 0 Then d = 4 b = 38 dk = 7 k = 2.6 n = 1.2 t = 1.1 ElseIf i = 1 Then d = 5 b = 38 dk = 8.5 k = 3.3 n = 1.2 t = 1.3 ElseIf i = 2 Then d = 6 b = 38 dk = 10 k = 3.9 n = 1.6 t = 1.6 ElseIf i = 3 Then d = 8 b = 38 dk = 13 k = 5 n = 2 t = 2 ElseIf i = 4 Then d = 10 b = 38 dk = 16 k = 6 n = 2.5 t = 2.4 End If 直线 Dim Scrline As AcadLine Dim Lline As AcadLine Dim Cline As AcadLine 变量 Dim p0(0 To 2) As Double, L As Variant 点 Dim p1(0 To 2) As Double Dim p2(0 To 2) As Double Dim p3(0 To 2) As Double Dim p4(0 To 2) As Double Dim p5(0 To 2) As Double Dim p6(0 To 2) As Double Dim p7(0 To 2) As Double Dim p8(0 To 2) As Double Dim p9(0 To 2) As Double Dim p10(0 To 2) As Double Dim p11(0 To 2) As Double Dim p12(0 To 2) As Double Dim p13(0 To 2) As Double Dim p14(0 To 2) As Double Dim p15(0 To 2) As Double Dim p16(0 To 2) As Double Dim p17(0 To 2) As Double Dim p18(0 To 2) As Double Dim pt1(0 To 2) As Double Dim pt2(0 To 2) As Double 线型的添加 Dim entry As AcadLineType: Dim found As Boolean: Dim ltName(0 To 2) As String Dim j As Integer found = False 准备添加的3种线型 ltName(0) = BORDER ltName(1) = CENTER ltName(2) = DASHDOT For j = 0 To 2 搜寻要添加的线型在线型集合中是否已存在 For Each entry In ThisDrawing.Linetypes If StrComp(entry.Name, ltName(j), 1) = 0 Then found = True Exit For End If Next 如果不存在则将其从线型文件acadiso.lin中加载 If Not (found) Then ThisDrawing.Linetypes.Load ltName(j), acadiso.lin End If Next 创建图层 Dim objLayer As AcadLayer 粗实线 Set objLayer = ThisDrawing.Layers.Add(粗实线) objLayer.color = acWhite objLayer.Linetype = Continuous objLayer.Lineweight = acLnWt035 ThisDrawing.ActiveLayer = objLayer p0(0) = Val(TextBox1.Text) 输入螺钉定点的X坐标 p0(1) = Val(TextBox2.Text) 输入螺钉定点的Y坐标 p0(2) = 0 L = Val(Combo2.Selected(m).Text) 输入螺钉的长度 Dim s As Double If L - b 0 Then s = 0 Else: s = L - b End If 计算各个点 p1(0) = p0(0): p1(1) = p0(1) + 0.5 * n: p1(2) = p0(2)p2(0) = p0(0): p2(1) = p0(1) - 0.5 * n: p2(2) = p0(2) p3(0) = p1(0) - t: p3(1) = p1(1): p3(2) = p1(2)p4(0) = p2(0) - t: p4(1) = p2(1): p4(2) = p2(2) p5(0) = p3(0): p5(1) = p3(1) + 0.5 * dk - 0.5 * n: p5(2) = p3(2) p6(0) = p4(0): p6(1) = p4(1) - 0.5 * dk + 0.5 * n: p6(2) = p4(2) p7(0) = p5(0) + k: p7(1) = p5(1): p7(2) = p5(2) p8(0) = p6(0) + k: p8(1) = p6(1): p8(2) = p6(2) p9(0) = p7(0): p9(1) = p7(1) - 0.5 * dk + 0.5 * d: p9(2) = p7(2) p10(0) = p8(0): p10(1) = p8(1) + 0.5 * dk - 0.5 * d: p10(2) = p8(2) p11(0) = p9(0) + s: p11(1) = p9(1): p11(2) = p9(2) p12(0) = p10(0) + s: p12(1) = p10(1): p12(2) = p10(2) p13(0) = p11(0): p13(1) = p11(1) - 0.075 * d: p13(2) = p11(2) p14(0) = p12(0): p14(1) = p10(1) + 0.075 * d: p14(2) = p12(2) p15(0) = p11(0) + b - 0.075 * d: p15(1) = p11(1): p15(2) = p11(2) p16(0) = p12(0) + b - 0.075 * d: p16(1) = p12(1): p16(2) = p12(2) p17(0) = p13(0) + b: p17(1) = p13(1): p17(2) = p13(2) p18(0) = p14(0) + b: p18(1) = p14(1): p18(2) = p14(2) pt1(0) = p0(0) - t - 3: pt1(1) = p0(1): pt1(2) = p0(2) pt2(0) = p17(0) + 3: pt2(1) = p0(1): pt2(2) = p0(2) 画出直线 Set Scrline = ThisDrawing.ModelSpace.AddLine(p1, p2) Set Scrline = ThisDrawing.ModelSpace.AddLine(p1, p3) Set Scrline = ThisDrawing.ModelSpace.AddLine(p2, p4) Set Scrline = ThisDrawing.ModelSpace.AddLine(p3, p5) Set Scrline = ThisDrawing.ModelSpace.AddLine(p4, p6) Set Scrline = ThisDrawing.ModelSpace.AddLine(p5, p7) Set Scrline = ThisDrawing.ModelSpace.AddLine(p6, p8) Set Scrline = ThisDrawing.ModelSpace.AddLine(p7, p8) Set Scrline = ThisDrawing.ModelSpace.AddLine(p9, p15) Set Scrline = ThisDrawing.ModelSpace.AddLine(p10, p16)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年C证安全员模拟题集及答案解析
- 2025年中小学英语教师面试英语预测题集
- 2025年美术教育专业能力测评试卷及答案解析
- 2025年旅游规划实务考试试题及答案解析
- 2025年劳动保护知识题库含答案
- 2025年技术经纪人入门面试题库及答案
- 2025年建筑建材工程师资格考试试题及答案解析
- 2025年环境卫生管理师专业资格考试试题及答案解析
- 2025年化学分析师专业资格考试试题及答案解析
- 2025年市场调研分析师职位面试指南及模拟题解答
- GB/T 45953-2025供应链安全管理体系规范
- 速冻机在果蔬加工中的应用考核试卷
- 2025年初级律师助理面试必-备题库及解析
- 增值税留抵退税培训课件
- 2025年秋季开学第一课《翻越你的浪浪山》课件
- DB11∕T 510-2024 公共建筑节能工程施工质量验收规程
- 部编版小学六年级上册《道德与法治》全册复习课件
- GJB标准化大纲
- 钢筋混凝土排水管二级管配筋设计图册
- 同济大学复变函数复变函数与积分变换课件
- 教导处行事历
评论
0/150
提交评论