Search This Blog

Thursday, January 03, 2008

Use VBA to detach unloaded External References (XREFs)

Often when archiving or sending files to consultants, it is desireable to do some house cleaning prior to transmitting them. A common practice in cases like these would be to detach any unnecessary XRefs. And what is more unnecessary than a previously unloaded xref?


Public Sub DetachUnloadedXrefs()
Dim o_Blk As AcadBlock
For Each o_Blk In ThisDrawing.Blocks
If o_Blk.IsXRef And o_Blk.Count = 0 Then
ThisDrawing.Utility.Prompt o_Blk.Name & _
" is an unloaded xref and has been detached." & vbCrLf
o_Blk.Detach
End If
Next
End Sub


Hope you find that useful.

No comments: