読み込んだシンボルを使用して、表示モデル内で使用したカスタマイズ済みシンボルを更新するには、その表示モデルを開いてグラフィックスを生成し、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)スクリプトを使用すると、1 回の操作で複数の表示モデルに対してシンボルを読み込むことができるため、時間の節約になります。サンプルのスクリプトを次に示します。このスクリプトに必要な修正を加え、.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
このサンプル スクリプトには、ImportSymbolIntoDisplayModel () という Sub 関数を持つ ImportSymbolInto_IM_DM というモジュールが記述されています。このスクリプトで、表示モデルの数、DWT ファイルのパス、.tbdm ファイルのパスを変更する必要があります。
VBA スクリプトを使用して複数の表示モデルに対してシンボルを読み込むには
Autodesk AutoCAD VBA Enabler がインストールされていない場合は、Autodesk AutoCAD VBA Enabler のダウンロードを求めるメッセージが表示されます。
マクロに関する警告が表示された場合は、[マクロを有効にする]をクリックします。