Unload Xrefs

To unload an xref, use the Unload method. When you unload a referenced file that is not being used in the current drawing, the AutoCAD performance is enhanced by not having to read and display unnecessary drawing geometry or symbol table information. The xref geometry and that of any nested xref is not displayed in the current drawing until the xref is reloaded.

Unload an xref definition

This example attaches an external reference and then unloads the external reference. This example uses the 3D House.dwg file found in the sample directory. If you do not have this image, or if it is located in a different directory, insert a valid path and file name for the PathName variable.

Sub Ch10_UnloadingExternalReference()

	' Define external reference to be inserted
	Dim xrefHome As AcadBlock
	Dim xrefInserted As AcadExternalReference
	Dim insertionPnt(0 To 2) As Double
	Dim PathName As String
	insertionPnt(0) = 1
	insertionPnt(1) = 1
	insertionPnt(2) = 0
	PathName = "c:/AutoCAD 2008/sample/3D House.dwg"

	' Add the external reference
	Set xrefInserted = ThisDrawing.ModelSpace. _
			AttachExternalReference(PathName, "XREF_IMAGE", _
			insertionPnt, 1, 1, 1, 0, False)
	MsgBox "The external reference is attached."

	' Unload the external reference definition
	MsgBox "The external reference is unloaded."
	Exit Sub
	MsgBox Err.Description
End Sub