zhuxuhong 发表于 2005-6-26 16:15:00

请问在VB中能否使用OBJECTDBX技术?

<DIV>请问在VB中能否使用OBJECTDBX技术?</DIV>
<DIV>我试了好久总是提示,ACTIVEX 无法创建对象。</DIV>

雪山飞狐_lzh 发表于 2005-6-26 21:24:00

要先打开AutoCad

zhuxuhong 发表于 2005-6-27 08:09:00

我把CAD已经启动了,在Createobject("objectdbx.axdocument")时出错提示"无法创建ActiveX对象".我已经引用了Axdb15.tlb和Autocad库了啊。帮主帮帮我吧

zhuxuhong 发表于 2005-6-28 11:41:00

本帖最后由 作者 于 2005-6-28 12:14:18 编辑 <br /><br /> <DIV>已经可以了,谢谢</DIV>

waley111 发表于 2005-8-3 20:00:00

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