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/> objDbx.Open "c:\yaquan.dwg" <br/> For Each elem In objDbx.Blocks'将图形中的块添加到列表中<br/> If elem.Name = "yq-ls" Then<br/> blkName = elem.Name<br/> Exit For<br/> End If<br/> Next <br/> pnt(0) = 0: pnt(1) = 0: pnt(2) = 0<br/> Set blkObj(0) = objDbx.Blocks(blkName)<br/> objDbx.CopyObjects blkObj, obj_ModelSpace<br/> obj_ModelSpace.InsertBlock pnt, blkName, 1, 1, 1, 0<br/> '释放内存<br/> Set elem = Nothing<br/> Set objDbx = Nothing</p> 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") dbx 依旧好用,感谢
页:
[1]