这将直接打开绘图并检查是否有任何Xref's
只需向其提供要检查的文件名列表。
需要引用ObjectDBX,这在AutoCAD 2005中进行了测试。
- Function test()
- Dim Xrefcoll
- Set Xrefcoll = CheckForXrefs("c:\filename.dwg")
- End Function
- Function CheckForXrefs(FileName As String) As Variant
- Dim Block As AcadBlock
- Dim coll As New Collection
- Dim path As String
- Dim msg As String
- Dim oSpace As AcadBlock
- Set odbx = GetInterfaceObject("ObjectDBX.AxDbDocument.16")
- If Err Then
- ' MsgBox "Error with ObjectDBX object"
- Set odbx = Nothing
- Else
-
- Dim oFile As Object
- Dim fPath As String
- odbx.Open FileName
- For Each Block In odbx.Blocks
- On Error Resume Next
- path = Block.path
- If Len(path) > 0 Then
- coll.Add path
- End If
- path = ""
- Next
- For Each item In coll
- msg = msg & item & vbCr
- Next
- MsgBox msg
- End If
- theend:
- Set odbx = Nothing
- Set CheckForXrefs = coll
- End Function
|