assing 发表于 2007-2-6 12:07:00

ObjectDbx技术的版本问题?

<p>vb6.0和autocad2006,在工程/引用中也加上了类型库.16。希望自动插入另一个图里的图块,程序如下。问题:说什么实时错误,自动化错误。光标在<font color="#f73809">CreateObject出错</font></p><p>Dim objDbx<br/>Dim elem As Object<br/>Dim blkName As String<br/>Dim blkObj(0) As Object<br/>Dim pnt(0 To 2) As Double<br/><font color="#f73809">Set objDbx = CreateObject("ObjectDBX.AxDbDocument.16")</font><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; objDbx.Open "c:\yaquan.dwg"&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For Each elem In objDbx.Blocks'将图形中的块添加到列表中<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If elem.Name = "yq-ls" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; blkName = elem.Name<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit For<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp; pnt(0) = 0: pnt(1) = 0: pnt(2) = 0<br/>&nbsp;&nbsp;&nbsp; Set blkObj(0) = objDbx.Blocks(blkName)<br/>&nbsp;&nbsp;&nbsp; objDbx.CopyObjects blkObj, obj_ModelSpace<br/>&nbsp;&nbsp;&nbsp; obj_ModelSpace.InsertBlock pnt, blkName, 1, 1, 1, 0<br/>&nbsp;&nbsp;&nbsp; '释放内存<br/>&nbsp;&nbsp;&nbsp; Set elem = Nothing<br/>&nbsp;&nbsp;&nbsp; Set objDbx = Nothing</p>

biztech 发表于 2012-11-18 16:01:41

yshf 发表于 2013-3-28 23:17:38

ObjectDBX宿主是AutoCAD,你那种用法在AutoCAD VBA中也许是可以的,但VB6.0中需先建立宿主才能引用,可能的写法是(没有试过):
   Dim AcadApp As Object
   Dim objDbx As Object
   Set AcadApp = CreateObject("AutoCAD.Application.16.2")
   Set objDbx = AcadApp.GetInterfaceObject("ObjectDBX.AxDbDocument.16")

lanrenqing 发表于 2020-7-15 16:33:48

dbx 依旧好用,感谢
页: [1]
查看完整版本: ObjectDbx技术的版本问题?