在VB中写程序,连接CAD成功后,如何让CAD界面显示出来,下面是我写的连接CAD2004的代码,在CAD中画直线后,但看不到CAD界面,只有在关机时才提示保存文件.
Private Sub CallCAD() Dim acadApp As AcadApplication On Error Resume Next Set acadApp = GetObject(, "AutoCAD.Application") If Err Then Err.Clear Set acadApp = CreateObject("AutoCAD.Application") If Err Then MsgBox Err.Description Exit Sub End If End If Rem MsgBox "现在运行" + acadApp.Name + "版本号" + acadApp.Version
Dim acadDoc As AcadDocument Set acadDoc = acadApp.ActiveDocument
Dim LineObj As AcadLine Dim startPnt(0 To 2) As Double Dim endpnt(0 To 2) As Double startPnt(0) = 1 startPnt(1) = 1 startPnt(2) = 0 endpnt(0) = 5 endpnt(1) = 5 endpnt(2) = 0
Set LineObj = acadDoc.ModelSpace.AddLine(startPnt, endpnt) ZoomAll End Sub
|