如何在VB里加载CAD文件
1个回答
展开全部
Sub Ch2_ConnectToAcad()
On Error Resume Next
’ 连接至 AutoCAD 应用程序
Dim tmCAD As AcadApplication
Set tmCAD = GetObject _
(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set tmCAD = CreateObject _
("AutoCAD.Application.16")
If Err Then
MsgBox Err.Descri ption
Exit Sub
End If
End If
’ 连接至 AutoCAD 图形
tmCAD.Visible = True ’ 隐式地打开
tmCAD.Documents.Open "c:\123.dwg"
Set sSet = tmCAD.ActiveDocument.SelectionSets.Add("TEST")
tmCAD.ActiveDocument.SendCommand "_ai_selall" & Chr(13)
tmCAD.ActiveDocument.Export app.Path & "tempcad", "WMF", sSet
tmCAD.ActiveDocument.SelectionSets.Item("TEST").Delete
Picture1.Picture = LoadPicture(app.Path & "tempcad.wmf")
tmCAD.Documents.Close
tmCAD.Quit
Set tmCAD = Nothing
End Sub
On Error Resume Next
’ 连接至 AutoCAD 应用程序
Dim tmCAD As AcadApplication
Set tmCAD = GetObject _
(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set tmCAD = CreateObject _
("AutoCAD.Application.16")
If Err Then
MsgBox Err.Descri ption
Exit Sub
End If
End If
’ 连接至 AutoCAD 图形
tmCAD.Visible = True ’ 隐式地打开
tmCAD.Documents.Open "c:\123.dwg"
Set sSet = tmCAD.ActiveDocument.SelectionSets.Add("TEST")
tmCAD.ActiveDocument.SendCommand "_ai_selall" & Chr(13)
tmCAD.ActiveDocument.Export app.Path & "tempcad", "WMF", sSet
tmCAD.ActiveDocument.SelectionSets.Item("TEST").Delete
Picture1.Picture = LoadPicture(app.Path & "tempcad.wmf")
tmCAD.Documents.Close
tmCAD.Quit
Set tmCAD = Nothing
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询