CAD二次开发(附源程序)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1. The Object of Design:
Programming for drawing a screw, screw bolt or other graphics by using VLISP, VBA,
etc. illustrated in the figure 1-1.
Figure 1-1 Parametric Dimension for a Screw
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 为工具进行螺钉的参数化设计。参考《机械制图》课本,开槽圆柱头螺钉的部分表格如下所示。
Tabl e 1 Sl otted cheese head screws (from GB/T 65- 2000) mm
Method: 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
,k ,n ,
t parameters. The screw points identified, wired generation screw CAD
diagram. illustrated in the figure 1-2.
思路:取p0点为定位点,根据上表,选择螺钉规格和公称长度l ,确定螺钉的
,
k,n,t参数。从而将螺钉的各点确定,连线生成螺钉CAD图。如图1-2所示。
Figure 1-2Parametric design of screw method
2.process of programming
1.Open Microsoft Visual Basic editor window shown as figure 2-1,2-
2.
Figure 2-1Open the VBA editor window
Figure 2-2VBA Editor Initial window
2.Add process
Input the process name”screw1”in the editbox right on the “NAME”label of the dialog box ,select the “SUBPEROGRAM” in the area “TYPE”and “PUBLIC”in the the area “SCOPE”,then click the“OK”button on the open the VBA editor shown as figure 2-2.
Figure 2-2 VBA Editor Initial window
⑧Special attention:
运行程序时,当选择螺钉公称长度L的数据小于螺纹长度b的数值时,此时螺钉公称长度L的数据等于螺纹长度b的数值(在本程序中b=38),容错程序如下:Dim s As Double
If L - b < 0 Then
s = 0
Else: s = L - b
End If
此处输入L=35,运行程序,可知,Auto CAD绘制的螺钉为全螺纹螺钉。如图所示:
Option Explicit
Public i As Integer '声明全局变量
Public m As Integer
Private 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) = 40 If 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) = 50 ElseIf 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) = 60 ElseIf i = 3 Then
Combo2.List(0) = 10