您可以在單一作業中使用 MAPSYMBOLIMPORTEXPORT 指令或 Microsoft VBA 腳本匯入多個符號。
當您設定點、線或多邊形圖徵的型式時,「負載」選項可讓您匯入符號。您也可以使用 MAPSYMBOLIMPORTEXPORT 指令,如下所述。
若要使用使用者介面匯入符號
您可以匯入 DWG 檔中的圖塊作為符號。您也可以將符號資源庫 (*.layer)、向量符號 (*.xml )、填充線定義 (*.pat)、線型式 (*.lin ), 或點陣式影像 (*.gif、*.jpg *.bmp *.png) 匯入至符號資源庫。
若要不使用使用者介面匯入符號
CMDDIA 0 FILEDIA 0 _MAPSYMBOLIMPORTEXPORT _IMPORT "C:\data\MySymbols.dwg" _YES
若要節省時間,您可以在單一作業中使用 Microsoft Visual Basic for Applications (VBA) 腳本為多個圖面匯入符號。以下腳本是一個範例。您可以將其用做樣板、進行所需的修改,然後將其儲存為 .bas 檔案。
Attribute VB_Name = "ImportSymbolIntoDWG" Sub ImportSymbolIntoAllDWG() Dim fileSystemObject, fileSystemFolder, file, fileCollection Dim collectionOfFiles As New Collection Dim path As String ' Define where the DWG files are located path = "C:\Autodesk\DWGFiles" Dim prototypeDWG As String ' Define where the symbol(s) should be imported from prototypeDWG = "C:\Autodesk\Prototype\Prototype_GA_modified.dwg" Dim currentSDI As Integer currentSDI = ThisDrawing.GetVariable("SDI") If (currentSDI = 1) Then MsgBox "The functions works only with multiple drawings [SDI=0]" Exit Sub End If '' use this to request the path 'path = ThisDrawing.Utility.GetString(1, vbCrLf & "Enter the path of the DWG files to update: ") 'prototypeDWG = ThisDrawing.Utility.GetString(1, vbCrLf & "Enter the path of the prototype DWG: ") ThisDrawing.SetVariable "FILEDIA", 0 ThisDrawing.SetVariable "CMDDIA", 0 Set fileSystemObject = CreateObject("Scripting.FileSystemObject") Set fileSystemFolder = fileSystemObject.GetFolder(path) Set fileCollection = fileSystemFolder.Files For Each file In fileCollection If UCase(Right(file.Name, 4)) = UCase(".dwg") Then collectionOfFiles.Add file.path End If Next For Each drawing In collectionOfFiles Application.Documents.Open (drawing) ThisDrawing.SendCommand "_MAPSYMBOLIMPORTEXPORT" & vbCr & "_IMPORT" & vbCr & prototypeDWG & vbCr & "_YES" & vbCr ThisDrawing.Save ThisDrawing.Close Next drawing End Sub
在範例腳本中,有一個模組「ImportSymbolIntoDWG」(帶子模組「ImportSymbolIntoAllDWG()」)。您需要修改「路徑」變數來指定圖面所在的路徑,並修改「prototypeDWG」變數以指向包含要匯入之符號的 DWG 檔案。
若要為多個圖面匯入符號,請使用 VBA 腳本
如果您尚未安裝,系統會顯示一則訊息,告知您下載 Autodesk AutoCAD VBA Enabler。
如果系統向您發出有關巨集的警告,請按一下「啟用巨集」。