Private Function isopen() As AutoCAD.AcadApplication
創(chuàng)新互聯(lián)建站專注于茶陵網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供茶陵營銷型網(wǎng)站建設(shè),茶陵網(wǎng)站制作、茶陵網(wǎng)頁設(shè)計、茶陵網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)服務(wù),打造茶陵網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供茶陵網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
Try
dim CADapp_temp AutoCAD.AcadApplication = GetObject(, "AutoCAD.Application")
return CADapp_temp
Catch ex As Exception
Return Nothing
End Try
End Function
'調(diào)用上面的函數(shù),如果為nothing表示沒有打開,否則打開并返回對象
這個是vb.net教材里面的吧,我也是前兩天剛下的。遇到類似的問題,下面是我的解決辦法
首先要參考引用Autodesk.AutoCAD.Interop.dll還有Autodesk.AutoCAD.Interop.Common.dll
然后代碼有兩處也需要相應(yīng)修改,我用的是.NET 的 vb2008
'Dim AcadApp As AutoCAD.AcadApplication
Dim AcadApp As Autodesk.AutoCAD.Interop.AcadApplication
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call 連接AutoCAD()
End Sub
Sub 連接AutoCAD()
On Error Resume Next
AcadApp = GetObject(, "AutoCAD.Application")
If Err.Number Then
Err.Clear()
AcadApp = CreateObject("AutoCAD.Application")
If Err.Number Then
MsgBox("不能運(yùn)行AutoCAD,請檢查是否安裝了AutoCAD")
Exit Sub
End If
End If
AcadApp.Visible = True '界面可視
'AcadApp.WindowState = AutoCAD.AcWindowState.acMax '界面最大化
AcadApp.WindowState = Autodesk.AutoCAD.Interop.Common.AcWindowState.acMax
AppActivate(AcadApp.Caption) '顯示AutoCAD界面
End Sub
你去查查書吧,書上挺詳細(xì)的,在這說不好說,你先在項目里引用。然后 Dim acadapp As AcadApplication Dim acaddoc As AcadDocument On Error Resume Next AcadApp = GetObject(, "AutoCAD.Application") If Err.Number Then Err.Clear() AcadApp = CreateObject("AutoCAD.Application") If Err.Number Then MsgBox("不能運(yùn)行AutoCAD,請檢查是否安裝了AutoCAD") Exit Sub End If End If AcadApp.Visible = True '界面可視
你去查查書吧,書上挺詳細(xì)的,在這說不好說,你先在項目里引用。然后 Dim acadapp As AcadApplication Dim acaddoc As AcadDocument On Error Resume Next AcadApp = GetObject(, "AutoCAD.Application") If Err.Number Then Err.Clear() AcadApp = CreateObject("AutoCAD.Application") If Err.Number Then MsgBox("不能運(yùn)行AutoCAD,請檢查是否安裝了AutoCAD") Exit Sub End If End If AcadApp.Visible = True '界面可視