Unload Method (ActiveX)

Unloads the menu group or external reference.

Supported platforms: Windows only

Signature

VBA:

object.Unload
object

Type: ExternalReference, MenuGroup

The object this method applies to.

Return Value (RetVal)

No return value.

Remarks

ExternalReference: When an ExternalReference object (xref) is unloaded from the drawing, the drawing opens faster and uses less memory. An unloaded xref is not displayed and the xref-dependent symbol table information does not appear in the drawing. However, all the information can be restored by reloading the xref using the Reload method.

To unload an external reference, you must unload the block that defines the external reference. For example, the following line of VBA code unloads an external reference that is stored in the xrefInserted variable:

ThisDrawing.Blocks.Item(xrefInserted.name).Unload

MenuGroup: When a menu group is unloaded from the drawing, any references to the menus and toolbars within that group become invalid. Always delete or set to NULL any references to toolbars and menus that are in the menu group to be unloaded before you unload the menu group.

Examples

VBA:

Sub Example_Unload()
    On Error GoTo ERRORHANDLER
                          
    ' 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/sample/City map.dwg"
    
    ' Add the external reference
    Set xrefInserted = ThisDrawing.ModelSpace. _
            AttachExternalReference(PathName, "XREF_IMAGE", _
            insertionPnt, 1, 1, 1, 0, False)
    ZoomAll
    MsgBox "The external reference is attached."
    
    ' Unload the external reference definition
    ThisDrawing.Blocks.Item(xrefInserted.name).Unload
    MsgBox "The external reference is unloaded."
    Exit Sub
ERRORHANDLER:
    MsgBox Err.Description
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Unload()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
                         
    ;; Define external reference to be inserted
    (setq insertionPnt (vlax-3d-point 1 1 0)
          pathName (findfile ".\\Sample\\Sheet Sets\\Architectural\\Res\\STAIR1.dwg"))
    
    ;; Add the external reference to the block
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq xrefInserted (vla-AttachExternalReference modelSpace pathName "XREF_IMAGE" insertionPnt 1 1 1 0 :vlax-false))
    (vla-ZoomAll acadObj)
    (alert "The external reference is attached.")
    
    ;; Unload the external reference definition
    (vla-Unload (vla-Item (vla-get-Blocks doc) "XREF_IMAGE"))
    (vla-Regen doc :vlax-true)
    (alert "The external reference is unloaded.")

    ;; Reload the external reference definition
    (vla-Reload (vla-Item (vla-get-Blocks doc) "XREF_IMAGE"))
    (alert "The external reference is reloaded.")
)