MAPSYMBOLIMPORTEXPORT コマンドまたは Microsoft VBA スクリプトを使用すると、1 回の操作で複数のシンボルを読み込むことができます。
ポイント フィーチャ、ライン フィーチャ、ポリゴン フィーチャのスタイルを設定する際に、[ロード]オプションを使用してシンボルを読み込むことができます。また、以下で説明するように、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)スクリプトを使用すると、1 回の操作で複数の図面に対してシンボルを読み込むことができるため、時間の節約になります。サンプルのスクリプトを次に示します。このスクリプトに必要な修正を加え、.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
このサンプル スクリプトには、ImportSymbolIntoAllDWG() という Sub 関数を持つ ImportSymbolIntoDWG モジュールが記述されています。このスクリプトでは、path 変数を変更して図面の保存場所を指定し、prototypeDWG 変数を変更して、読み込んだシンボルを格納する DWG ファイルを指定する必要があります。
VBA スクリプトを使用して複数の図面に対してシンボルを読み込むには
Autodesk AutoCAD VBA Enabler がインストールされていない場合は、Autodesk AutoCAD VBA Enabler のダウンロードを指示するメッセージが表示されます。
マクロに関する警告が表示された場合は、[マクロを有効にする]をクリックします。