本帖最后由 作者 于 2007-2-6 16:08:42 编辑
vb6.0和AutoCAD2006,在工程/引用中也加上了类型库.16。希望自动插入另一个图里的图块,程序如下。问题:说什么实时错误,自动化错误。光标在CreateObject出错 Dim objDbx Dim elem As Object Dim blkName As String Dim blkObj(0) As Object Dim pnt(0 To 2) As Double Set objDbx = CreateObject("ObjectDBX.AxDbDocument.16") objDbx.Open "c:\yaquan.dwg" For Each elem In objDbx.Blocks'将图形中的块添加到列表中 If elem.Name = "yq-ls" Then blkName = elem.Name Exit For End If Next pnt(0) = 0: pnt(1) = 0: pnt(2) = 0 Set blkObj(0) = objDbx.Blocks(blkName) objDbx.CopyObjects blkObj, obj_ModelSpace obj_ModelSpace.InsertBlock pnt, blkName, 1, 1, 1, 0 '释放内存 Set elem = Nothing Set objDbx = Nothing |