To Import Symbols

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

  1. Set the CMDDIA or FILEDIA system variable to '1'.
  2. At the Command prompt, enter MAPSYMBOLIMPORTEXPORT.
  3. In the Symbol Repository, click Import.
  4. 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.

  5. Click Close.

To import symbols without using a user interface

  1. Set both CMDDIA and FILEDIA system variables to '0'.
  2. At the Command prompt, enter MAPSYMBOLIMPORTEXPORT.
  3. Following the prompt, choose Import.
  4. Enter the path to the symbol file that contains the symbols you want to import.
  5. 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.
  6. Wait until you see the message 'The symbol import has finished successfully!'.
Tip: As an option, you can automatically complete the steps above by script. In the command line, load the script file with the SCRIPT command and wait until finished. Following is an example of a script. Save it as a file with .scr extension.
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

  1. Put in one folder all the drawings for which you want to update symbols.
  2. 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.

  3. In the Microsoft VBA window, do the following:
    1. Click the File and select Import File.
    2. In the Import File dialog box, find and select the .bas file that contains the script.
    3. Click Open.
    4. In the Microsoft VBA window, Click Save.
    5. In the Save As dialog box, specify the path and file name, then click Save.
  4. Close the Microsoft VBA window.
  5. 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.

  6. On the command line, enter VBARUN and choose the related macro to run.