You can import multiple symbols in a single operation, using the command MAPSYMBOLIMPORTEXPORT or a Microsoft VBA script.
When you style Point, Line or Polygon features, the Load Option allows you to import a symbol. You can also use the command MAPSYMBOLIMPORTEXPORT, as described below.
To import symbols using a user interface
- Set the CMDDIA or FILEDIA system variable to '1'.
- At the Command prompt, enter MAPSYMBOLIMPORTEXPORT.
- In the Symbol Repository, click Import.
- In the
Open dialog box, find and select the file you want to import, or enter the name of the file at
Filename, and click
Open.
You can import blocks in DWG files as symbols. You can also import a symbol library (*.layer), a vector symbol (*.xml), hatch definition (*.pat), line style (*.lin), or raster images (*.gif, *.jpg *.bmp *.png) to the symbol repository.
- Click Close.
To import symbols without using a user interface
- Set both CMDDIA and FILEDIA system variables to '0'.
- At the Command prompt, enter MAPSYMBOLIMPORTEXPORT.
- Following the prompt, choose Import.
- Enter the path to the symbol file that contains the symbols you want to import.
- Choose Yes if you want to replace the existing symbols that have the same name, or No if you don't want to overwrite the symbols with same name.
- Wait until you see the message 'The symbol import has finished successfully!'.
CMDDIA 0 FILEDIA 0 _MAPSYMBOLIMPORTEXPORT _IMPORT "C:\data\MySymbols.dwg" _YES
VBA Script Option
To save time, you can import the symbols for many drawings in a single operation, using a Microsoft Visual Basic for Applications (VBA) script. The following script is a sample. You can use it as a template, make the required modifications, and then save it as a .bas file.
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
In the example script, there is a module "ImportSymbolIntoDWG" with a sub "ImportSymbolIntoAllDWG()". You need to modify the "path" variable to specify the path where the drawings are located, and modify the "prototypeDWG" variable to point to the DWG file that contains the symbols you want to import.
To import symbols for multiple drawings, using a VBA script
- Put in one folder all the drawings for which you want to update symbols.
- On the AutoCAD Map 3D toolset command line, enter VBAIDE to open the Microsoft VBA window.
A message tells you to download the Autodesk AutoCAD VBA Enabler if you have not already installed it.
- In the Microsoft VBA window, do the following:
- Click the File and select Import File.
- In the Import File dialog box, find and select the .bas file that contains the script.
- Click Open.
- In the Microsoft VBA window, Click Save.
- In the Save As dialog box, specify the path and file name, then click Save.
- Close the Microsoft VBA window.
- On the command line, enter VBALOAD to load the .dvb file you saved above.
If the system warns you about the macros, click Enable Macros.
- On the command line, enter VBARUN and choose the related macro to run.