È possibile importare più simboli in una sola operazione, utilizzando il comando MAPSYMBOLIMPORTEXPORT o uno script Microsoft VBA.
Quando si definiscono le entità geografiche per Punto, Linea o Poligono, l'opzione Carica consente di importare un simbolo. È inoltre possibile utilizzare il comando MAPSYMBOLIMPORTEXPORT, come descritto di seguito.
Come importare simboli utilizzando un'interfaccia utente
È possibile importare blocchi nel file DWG come simboli. È inoltre possibile importare una libreria di simboli (*.layer), un simbolo vettore (*.xml), una definizione di tratteggio (*.pat), uno stile di linea (*.lin) o immagini raster (*.gif, *.jpg *.bmp *.png) nel catalogo simboli.
Come importare simboli senza utilizzare un'interfaccia utente
CMDDIA 0 FILEDIA 0 _MAPSYMBOLIMPORTEXPORT _IMPORT "C:\data\MySymbols.dwg" _YES
Per risparmiare tempo, è possibile importare i simboli per molti disegni in un'unica operazione mediante l'utilizzo di uno script Microsoft Visual Basic for Applications (VBA). Lo script riportato di seguito è un esempio. Può essere utilizzato come modello, apportare le necessarie modifiche e salvarlo come file .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
Nello script di esempio, è presente un modulo "ImportSymbolIntoDWG" con un modulo secondario "ImportSymbolIntoAllDWG()". È necessario modificare la variabile "path" per specificare il percorso in cui si trovano i disegni e modificare la variabile "prototypeDWG" da puntare al file DWG contenente i simboli che si desidera importare.
Come importare simboli per più disegni utilizzando uno script VBA
Viene visualizzato un messaggio che indica di scaricare Autodesk AutoCAD VBA Enabler se non è stato già installato.
Se il sistema avvisa circa le macro, fare clic su Abilita macro.