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
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.
To import symbols without using a user interface
CMDDIA 0 FILEDIA 0 _MAPSYMBOLIMPORTEXPORT _IMPORT "C:\data\MySymbols.dwg" _YES
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
A message tells you to download the Autodesk AutoCAD VBA Enabler if you have not already installed it.
If the system warns you about the macros, click Enable Macros.