我也遇到了同样的问题,请问楼主你是怎么解决的?
我开始出错是ACTIVEX 无法创建对象。后来是变成了“自动化出错”
我的源码如下:
希望楼主帮忙看一下,很简单,就是打开一图形,取出叫111的图块插入当前文件中
Private Sub Command1_Click()
On Error Resume Next ' 连接至 AutoCAD 应用程序 Dim acadApp As Object Set acadApp = GetObject(, "AutoCAD.Application.15") If Err Then Err.Clear Set acadApp = CreateObject("AutoCAD.Application.15") If Err Then MsgBox Err.Description Exit Sub End If End If ' 连接至 AutoCAD 图形 Dim acadDoc As Object Set acadDoc = acadApp.ActiveDocument Dim blkname As String '图块名 Dim dwgname As String ‘要打开的dwg文件名字 Dim blkobj(0) As Object Dim pnt(2) As Double Dim objdbx '根据AutoCAD的版本来确定使用ObjectDBX的版本 '我的是cad2002
'此句出错
Set objdbx = CreateObject("ObjectDBX.AxDbDocument") If Err Then Set objdbx = CreateObject("ObjectDBX.AxDbDocument.16") End If
blkname = "111" dwgname = "d:\111.dwg" objdbx.Open dwgname pnt(0) = 0 pnt(1) = 0 pnt(2) = 0 Set blkobj(0) = objdbx.Blocks(blkname) objdbx.CopyObjects blkobj, acadDoc.ModelSpace acadDoc.ModelSpace.InsertBlock pnt, blkname, 1, 1, 1, 0 ZoomAll acadApp.Visible = True acadApp.ZoomAll End Sub
|