1、Report of Processing for Line Graph Name: NO.: Expecting Score:Introduction of Line Graph :The design goal is to write by the program to draw the screw 2 d graphics (using VB programming language).该设计的目标是通过程序编写来画出螺钉的二维图形(采用 VB 语言进行编程)According to the related point position, VBA programming, and desi
2、gn results.根据相关点的位置关系,进行VBA编程,从而得设计结果。 Ideas: p0 points according to the anchor point, for other points and its relationship to calculate. Prompted for the screw diameter and length, the screw CAD drawing. 思路:取p0 点为定位点,根据其它点与其的关系进行计算。提示输入螺钉直径和长度,生成螺钉CAD图。 打开 Autocad 软件,导入已经写好关于螺钉画法的程序Open the Autoca
3、d software, import the drawing program has been written about the screw运行程序,在弹出的对话框中输入相关参数To run the program, in the pop-up dialog box enter the relevant parameters回到 CAD 绘图模式下,给已经画好的图进行相关尺寸标注,并检验其正确性Back to the CAD drawing mode, to draw has a good figure for related dimensioning, and verify its cor
4、rectnessProgram codes:Private Sub CommandButton1_Click()Dim Culine As AcadLine 定义直线的对象变量Dim Xiline As AcadLineDim Dhline As AcadLineDim p0(0 To 2) As Double, d As Variant, L As Variant 定义三个变体变量Dim p1(0 To 2) As Double 定义保存点的双精度数组Dim p2(0 To 2) As DoubleDim p3(0 To 2) As DoubleDim p4(0 To 2) As Doubl
5、eDim p5(0 To 2) As DoubleDim p6(0 To 2) As DoubleDim p7(0 To 2) As DoubleDim p8(0 To 2) As DoubleDim p9(0 To 2) As DoubleDim p10(0 To 2) As DoubleDim p11(0 To 2) As DoubleDim p12(0 To 2) As DoubleDim p13(0 To 2) As DoubleDim p14(0 To 2) As DoubleDim p15(0 To 2) As DoubleDim p16(0 To 2) As DoubleDim
6、p17(0 To 2) As DoubleDim p18(0 To 2) As DoubleDim pt1(0 To 2) As DoubleDim pt2(0 To 2) As DoubleDim entry As AcadLineType:Dim found As Boolean:Dim ltName(0 To 2) As StringDim i As Integerfound = FalseltName(0) = “BORDER“ltName(1) = “CENTER“ltName(2) = “DASHDOT“For i = 0 To 2For Each entry In ThisDra
7、wing.LinetypesIf StrComp(entry.Name, ltName(i), 1) = 0 Thenfound = TrueExit ForEnd IfNextIf Not (found) ThenThisDrawing.Linetypes.Load ltName(i), “acadiso.lin“End IfNextDim objLayer As AcadLayerSet objLayer = ThisDrawing.Layers.Add(“粗实线“)objLayer.color = acWhiteobjLayer.Linetype = “Continuous“objLay
8、er.Lineweight = acLnWt030ThisDrawing.ActiveLayer = objLayerp0(0) = Val(InputBox(“X 坐标 : “) 输入螺钉定点的 X 坐标p0(1) = Val(InputBox(“Y 坐标 : “) 输入螺钉定点的 Y 坐标p0(2) = 0 定好 p0 点 d = Val(InputBox(“公称直径 D: “) 输入螺钉的公称直径L = Val(InputBox(“公称长度 L: “) 输入螺钉的公称长度p1(0) = p0(0): p1(1) = p0(1) + 0.1 * d: p1(2) = p0(2) 分别计算
9、p1p18 点坐标p2(0) = p0(0): p2(1) = p0(1) - 0.1 * d: p2(2) = p0(2)p3(0) = p1(0) - 0.2 * d: p3(1) = p1(1): p3(2) = p1(2)p4(0) = p2(0) - 0.2 * d: p4(1) = p2(1): p4(2) = p2(2)p5(0) = p3(0): p5(1) = p3(1) + 0.9 * d: p5(2) = p3(2)p6(0) = p4(0): p6(1) = p4(1) - 0.9 * d: p6(2) = p4(2)p7(0) = p5(0) + 0.7 * d: p
10、7(1) = p5(1): p7(2) = p5(2)p8(0) = p6(0) + 0.7 * d: p8(1) = p6(1): p8(2) = p6(2)p9(0) = p7(0): p9(1) = p7(1) - 0.5 * d: p9(2) = p7(2)p10(0) = p8(0): p10(1) = p8(1) + 0.5 * d: p10(2) = p8(2)p11(0) = p9(0) + L - 2 * d: p11(1) = p9(1): p11(2) = p9(2)p12(0) = p10(0) + L - 2 * d: p12(1) = p10(1): p12(2)
11、= 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) = p9(0) + L - 0.075 * d: p15(1) = p9(1): p15(2) = p11(2)p16(0) = p10(0) + L - 0.075 * d: p16(1) = p10(1): p16(2) = p12(2)p17(0) = p9(0) + L: p17(1) = p13(1): p17(2
12、) = p13(2)p18(0) = p10(0) + L: p18(1) = p14(1): p18(2) = p14(2)pt1(0) = p0(0) - 0.2 * d - 7: pt1(1) = p0(1): pt1(2) = p0(2) 分别计算 pt1 和 pt2 点 坐标pt2(0) = p0(0) + 0.6 * d + L + 7: pt2(1) = p0(1): pt2(2) = p0(2)Set Culine = ThisDrawing.ModelSpace.AddLine(p0, p1) 连接各点,画出直线Set Culine = ThisDrawing.ModelSp
13、ace.AddLine(p0, p2)Set Culine = ThisDrawing.ModelSpace.AddLine(p1, p3)Set Culine = ThisDrawing.ModelSpace.AddLine(p2, p4)Set Culine = ThisDrawing.ModelSpace.AddLine(p3, p5)Set Culine = ThisDrawing.ModelSpace.AddLine(p4, p6)Set Culine = ThisDrawing.ModelSpace.AddLine(p5, p7)Set Culine = ThisDrawing.M
14、odelSpace.AddLine(p6, p8)Set Culine = ThisDrawing.ModelSpace.AddLine(p7, p8)Set Culine = ThisDrawing.ModelSpace.AddLine(p9, p15)Set Culine = ThisDrawing.ModelSpace.AddLine(p10, p16)Set Culine = ThisDrawing.ModelSpace.AddLine(p11, p12)Set Culine = ThisDrawing.ModelSpace.AddLine(p17, p18)Set Culine =
15、ThisDrawing.ModelSpace.AddLine(p15, p17)Set Culine = ThisDrawing.ModelSpace.AddLine(p16, p18)Set Culine = ThisDrawing.ModelSpace.AddLine(p15, p16)Set objLayer = ThisDrawing.Layers.Add(“细实线“)objLayer.color = acWhiteobjLayer.Linetype = “Continuous“objLayer.Lineweight = acLnWt009ThisDrawing.ActiveLayer
16、 = objLayerSet Xiline = ThisDrawing.ModelSpace.AddLine(p13, p17)Xiline.Linetype = “ByLayer“Set Xiline = ThisDrawing.ModelSpace.AddLine(p14, p18)Xiline.Linetype = “ByLayer“Set objLayer = ThisDrawing.Layers.Add(“点划线“)objLayer.color = acRedobjLayer.Linetype = “CENTER“objLayer.Lineweight = acLnWt009ThisDrawing.ActiveLayer = objLayerSet Dhline = ThisDrawing.ModelSpace.AddLine(pt1, pt2)Dhline.Linetype = “ByLayer“End Sub