若要使用匯入的符號更新顯示模型

如果您已在顯示模型中使用自訂符號,並想要使用已修改的符號將其更新,可以開啟顯示模型、產生圖形,並使用 MAPSYMBOLIMPORTEXPORT 匯入修改的符號。如需詳細資訊,請參閱〈若要匯入符號〉

    若要在不使用使用者介面的情況下成批匯入符號

  1. 「全球產業模型選項」 「產生圖形」中, 選取「重複使用目前的圖面」
  2. 開啟顯示模型適用的專案,並使用空白圖面開始。
  3. 同時將 CMDDIA 和 FILEDIA 系統變數設定為 '0' (零)。
  4. 於指令提示下,輸入TBDMOPEN。
  5. 於發出提示後,輸入要修改的顯示模型的路徑。
  6. 輸入 TBGENERATEGRAPHIC 指令。
  7. 輸入 MAPSYMBOLIMPORTEXPORT 指令。
  8. 於發出提示後,選擇「匯入」。
  9. 輸入包含要匯入之符號的符號檔案路徑。
  10. 選取一個匯入選項以指定您要在使用者介面中選取符號的方式。
  11. 完成匯入,然後輸入 TBDMSAVE 指令。

或者,您可以透過腳本自動完成上述步驟。在指令行中,使用「腳本」指令載入腳本檔並等待直到完成。當您為不同顯示模型執行多種腳本時,請確保永遠以空白圖面開始,再開啟顯示模型。否則,您會將上一個圖面中的舊圖層儲存至新的顯示模型。

以下是一個範例腳本。您可以將其儲存為帶 .scr 的檔案。

CMDDIA 0
FILEDIA 0
_TBDMOPEN [path to your TBDM file]
_TBGENERATEGRAPHIC
_MAPSYMBOLIMPORTEXPORT _IMPORT [choose options that fit your needs]
_TBDMSAVE
當您新增完該腳本後,請將 CMDDIA 和 FILEDIA 設回至其原始值,通常為 '1'。

VBA 腳本選項

若要節省時間,您可以在單一作業中使用 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 腳本為多個顯示模型匯入符號

  1. 在 Map 3D 指令行輸入 VBAIDE,以開啟「Microsoft VBA」視窗。

    如果您尚未安裝,系統會顯示一則訊息,告知您下載 Autodesk AutoCAD VBA Enabler。

  2. 在「Microsoft VBA」視窗中,執行以下作業:
    1. 按一下「檔案」, 並選取「匯入檔案」
    2. 「匯入檔案」對話方塊中,尋找並選取包含腳本的 .bas 檔案。
    3. 按一下「開啟」
    4. 在「Microsoft VBA」視窗中,按一下「儲存」
    5. 「另存」對話方塊中,指定路徑與檔案名稱,然後按一下「儲存」
  3. 關閉「Microsoft VBA」視窗。
  4. 在指令行上,輸入 VBALOAD 以載入您在上方儲存的 .dvb 檔。

    如果系統向您發出有關巨集的警告,請按一下「啟用巨集」。

  5. 在指令行上,輸入 VBARUN 並選擇相關的巨集以執行。