Private Sub Command1_Click() Dim a, b As Single Dim lineobj As AutoCAD.AcadLWPolyline Dim points(9) As Double Acadapp = GetObject(, "autocad.application") If Err.Number Then Err.Clear() Acadapp = CreateObject("autocad.application") If Err.Number Then MsgBox("不能运行AutoCAD") Exit Sub End If End If Acadapp.Visible = True a = Val(TextBox1.Text) b = Val(TextBox2.Text) points(0) = 0 : points(1) = 0 points(2) = points(0) + a : points(3) = points(1) points(4) = points(2) : points(5) = points(3) + b points(6) = points(0) : points(7) = points(5) points(8) = points(0) : points(9) = points(1) lineobj = Acadapp.ActiveDocument.ModelSpace.AddLightWeightPolyline(points) Acadapp.ZoomAll() End Sub 在VB.NET 2003中调试通过. |