Private Sub Command1_Click()
Dim acadApp As AcadApplication
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
MsgBox "Now running " + acadApp.Name + _
" version " + acadApp.Version
End Sub
Private Sub Command2_Click()
On Error Resume Next
' Connect to the AutoCAD application' Connect to the AutoCAD application
Dim acadApp As AcadApplication
Dim acadApp As AcadApplication
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
' Connect to the AutoCAD drawing
Dim acadDoc As AcadDocument
Set acadDoc = acadApp.ActiveDocument
' Establish the endpoints of the line
Dim lineObj As AcadLine
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
startPoint(0) = 1
startPoint(1) = 1
startPoint(2) = 0
endPoint(0) = 5
endPoint(1) = 5
endPoint(2) = 0
' create a Line object in model space
Set lineObj = acadDoc.ModelSpace.AddLine _
(startPoint, endPoint)
ZoomAll
End Sub
Private Sub Form_Load()
End Sub
想用上面的程序实现vb和cad的连接并绘图,但是运行时出现了下面的提示,点确定也没用,,是哪里出问题了?
Dim acadApp As AcadApplication
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
MsgBox "Now running " + acadApp.Name + _
" version " + acadApp.Version
End Sub
Private Sub Command2_Click()
On Error Resume Next
' Connect to the AutoCAD application' Connect to the AutoCAD application
Dim acadApp As AcadApplication
Dim acadApp As AcadApplication
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
' Connect to the AutoCAD drawing
Dim acadDoc As AcadDocument
Set acadDoc = acadApp.ActiveDocument
' Establish the endpoints of the line
Dim lineObj As AcadLine
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
startPoint(0) = 1
startPoint(1) = 1
startPoint(2) = 0
endPoint(0) = 5
endPoint(1) = 5
endPoint(2) = 0
' create a Line object in model space
Set lineObj = acadDoc.ModelSpace.AddLine _
(startPoint, endPoint)
ZoomAll
End Sub
Private Sub Form_Load()
End Sub
想用上面的程序实现vb和cad的连接并绘图,但是运行时出现了下面的提示,点确定也没用,,是哪里出问题了?