如果您已在顯示模型中使用自訂符號,並想要使用已修改的符號將其更新,可以開啟顯示模型、產生圖形,並使用 MAPSYMBOLIMPORTEXPORT 匯入修改的符號。如需詳細資訊,請參閱〈若要匯入符號〉。
若要在不使用使用者介面的情況下成批匯入符號
「產生圖形」中, 選取「重複使用目前的圖面」。
或者,您可以透過腳本自動完成上述步驟。在指令行中,使用「腳本」指令載入腳本檔並等待直到完成。當您為不同顯示模型執行多種腳本時,請確保永遠以空白圖面開始,再開啟顯示模型。否則,您會將上一個圖面中的舊圖層儲存至新的顯示模型。
以下是一個範例腳本。您可以將其儲存為帶 .scr 的檔案。
CMDDIA 0 FILEDIA 0 _TBDMOPEN [path to your TBDM file] _TBGENERATEGRAPHIC _MAPSYMBOLIMPORTEXPORT _IMPORT [choose options that fit your needs] _TBDMSAVE當您新增完該腳本後,請將 CMDDIA 和 FILEDIA 設回至其原始值,通常為 '1'。
若要節省時間,您可以在單一作業中使用 Microsoft Visual Basic for Applications (VBA) 腳本為多個顯示模型匯入符號。以下腳本是一個範例。您可以將其用做樣板、進行所需的修改,然後將其儲存為 .bas 檔案。
Attribute VB_Name = "ImportSymbolInto_IM_DM"
Sub ImportSymbolIntoDisplayModel()
Dim prototypeDWG, templateDWT As String
Dim FileDia, CmdDia As Integer
Dim displayModelArray(0 To 2) As String 'TODO: Adapt to the number of Display Models to update
' TODO - Adapt to your settings
' Define the path to the Display Models for updating the symbol(s)
' When adding or removing Display Models, please adapt also the size of displayModelArray
' and the loop over all Display Models
displayModelArray(0) = "C:\TEST\DM1\DM1.tbdm"
displayModelArray(1) = " C:\TEST\DM2\DM2.tbdm"
displayModelArray(2) = " C:\TEST\DM3\DM3.tbdm"
' Attention !!!
' Only use the "Generic Graphic" - Application option: Reuse current drawings
' We need the same drawing for all operations !
' TODO - Adapt to your settings
' Define where the symbol(s) should be imported from
prototypeDWG = "C:\temp\symbol_modified.dwg "
' TODO - Adapt to your settings
' Define the template file to be used when open a new DWG
templateDWT = "c:\temp\Template\map2d.dwt"
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
FileDia = ThisDrawing.GetVariable("FILEDIA")
CmdDia = ThisDrawing.GetVariable("CMDDIA")
ThisDrawing.SetVariable "FILEDIA", 0
ThisDrawing.SetVariable "CMDDIA", 0
' Loop all Display Models
For inti = 0 To 2
' Open an empty drawing
Application.Documents.Open (templateDWT)
' Open the Display Model
ThisDrawing.SendCommand "_TBDMOPEN" & vbCr & displayModelArray(inti) & vbCr
ThisDrawing.SendCommand "_TBGENERATEGRAPHIC" & vbCr
' Import the symbol and apply changes to the layers
ThisDrawing.SendCommand "_MAPSYMBOLIMPORTEXPORT" & vbCr & "_IMPORT" & vbCr & prototypeDWG & vbCr & "_YES" & vbCr
' Save the changes of the layers to the Display Model
ThisDrawing.SendCommand "_TBDMSAVE" & vbCr
' Do not save the drawing
ThisDrawing.Close (False)
Next
' Reset the system variables
ThisDrawing.SetVariable "FILEDIA", FileDia
ThisDrawing.SetVariable "CMDDIA", CmdDia
End Sub
在範例腳本中,有一個模組「ImportSymbolInto_IM_DM」(帶子模組「ImportSymbolIntoDisplayModel ()」)。您需要調整顯示模型和路徑的數目,以適應 DWT 和 .tbdm 檔案。
若要使用 VBA 腳本為多個顯示模型匯入符號
如果您尚未安裝,系統會顯示一則訊息,告知您下載 Autodesk AutoCAD VBA Enabler。
如果系統向您發出有關巨集的警告,請按一下「啟用巨集」。