【发布时间】:2010-11-28 17:28:11
【问题描述】:
我正在使用这个在另一个中插入一个外部 dwg 文件:
Set xrefInserted = ThisDrawing.ModelSpace.AttachExternalReference(refDwgName, refDwgName, insertionPnt, 1, 1, 1, 0, False)
xrefInserted.Update
这是作为外部块插入的,所以我将它绑定到我的绘图:
For Each tempBlock In ThisDrawing.Blocks
If tempBlock.IsXRef Then
If (InStr(1, UCase(tempBlock.name), "MAJ_MATRICE", vbTextCompare)) Then
tempBlock.Bind (False)
Exit For
End If
End If
Next
现在我要炸了,首先AcadBlock好像没有和炸方法,只有AcadBlockReference。
所以我寻找参考:
Dim ent As AcadEntity
Dim blockRefObj As AcadBlockReference
For Each ent In ThisDrawing.ModelSpace
If TypeOf ent Is AcadBlockReference Then
If (InStr(1, UCase(ent.name), "MAJ_MATRICE", vbTextCompare)) Then
Set blockRefObj = ent
blockRefObj.Explode
Exit For
End If
End If
Next
问题是
blockRefObj.Explode
失败了,它告诉我“无效 -2145386494”。
我调试了代码,我相信问题是因为 AcadBlockReference 仍然是 AcadExternalReference 类型,并且无法分解外部引用。
如果我在返回绘图后重新运行代码(函数调用已结束)并查找 AcadBlockReference,它现在是 AcadBlockReference 类型,我可以正确分解它。
我似乎无法在同一个函数中完成它,在同一个执行中作为绑定它。
【问题讨论】:
-
blockRefObj 和 ent 的 Dim 语句在哪里?
-
您是否尝试过使用 Bind(True)? (只是为了调试)
-
你好,我刚试过,同样的错误