卸载外部参照
From AutoCAD ActiveX/VBA
要卸载外部参照,请使用 Unload 方法。卸载未在当前图形中使用的参照文件时,AutoCAD 的性能会有所提高,因为这样就不必读取和显示不必要的几何图形或符号表信息。加载外部参照之前,不会显示外部参照几何图形和任何外部参照的嵌套的外部参照几何图形。
本例附着外部参照,然后卸载外部参照。本例使用位于“Sample”目录中的“ 3D House.dwg ”文件。如果没有此图像,或者此图像位于其他目录中,请为 PathName 变量插入有效的路径和文件名。
Sub Ch10_UnloadingExternalReference()
On Error GoTo ERRORHANDLER
' 定义要插入的外部参照Dim xrefHome As AcadBlockDim xrefInserted As AcadExternalReferenceDim insertionPnt(0 To 2) As DoubleDim PathName As StringinsertionPnt(0) = 1insertionPnt(1) = 1insertionPnt(2) = 0PathName = "c:/AutoCAD 2008/sample/3D House.dwg"' 添加外部参照Set xrefInserted = ThisDrawing.ModelSpace. _AttachExternalReference(PathName, "XREF_IMAGE", _insertionPnt, 1, 1, 1, 0, False)ZoomAllMsgBox "The external reference is attached."' 卸载外部参照定义ThisDrawing.Blocks.Item(xrefInserted.name).UnloadMsgBox "The external reference is unloaded."Exit SubERRORHANDLER:MsgBox Err.DescriptionEnd Sub