我正在使用这个在另一个中插入一个外部 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 类型,我可以正确地分解它。
我似乎无法在同一个函数中完成它,在与绑定它相同的执行中。