Vous pouvez importer des symboles en une seule opération à l'aide de la commande MAPSYMBOLIMPORTEXPORT ou d'un script Microsoft VBA.
Lorsque vous appliquez un style à des objets Point, Ligne ou Polygone, l'option Charger vous permet d'importer un symbole. Vous pouvez également utiliser la commande MAPSYMBOLIMPORTEXPORT, comme indiqué ci-dessous.
Pour importer des symboles à l'aide d'une interface utilisateur
Vous pouvez importer des blocs dans des fichiers DWG en tant que symboles. Vous pouvez également importer une bibliothèque de symboles (*.layer), un symbole de vecteur (*.xml), une définition de hachures (*.pat), un style de ligne (*.lin) ou des images raster (*.gif, *.jpg, *.bmp, *.png) dans le référentiel de symboles.
Pour importer des symboles sans avoir recours à l'interface utilisateur
CMDDIA 0 FILEDIA 0 _MAPSYMBOLIMPORTEXPORT _IMPORT "C:\data\MySymbols.dwg" _YES
Pour gagner du temps, vous pouvez importer les symboles pour de nombreux dessins en une seule opération à l'aide d'un script Microsoft VBA (Visual Basic for Applications). Le script suivant est un exemple. Vous pouvez l'utiliser en tant que modèle, apporter les modifications requises, puis l'enregistrer en tant que fichier .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
L'exemple de script comporte un module "ImportSymbolIntoDWG" avec un sous-module "ImportSymbolIntoAllDWG()". Vous devez modifier la variable "path" pour spécifier le chemin où sont stockés les dessins et modifier la variable "prototypeDWG" afin qu'elle pointe vers le fichier DWG qui contient les symboles à importer.
Pour importer des symboles pour plusieurs dessins à l'aide d'un script VBA
Un message s'affiche pour vous inviter à télécharger Autodesk AutoCAD VBA Enabler si vous ne l'avez pas installé.
Si le système affiche un avertissement au sujet des macros, cliquez sur Activer les macros.