Wenn Sie in Ihren Darstellungsmodellen benutzerdefinierte Symbole verwendet haben und sie mit geänderten Symbolen aktualisieren möchten, können Sie das Darstellungsmodell öffnen, die Grafik generieren und die geänderten Symbole mit dem Befehl MAPSYMBOLIMPORTEXPORT importieren. Weitere Informationen finden Sie unter So importieren Sie Symbole.
So importieren Sie Symbole ohne Benutzeroberfläche in einem Stapel
Alternativ dazu können Sie die oben beschriebenen Schritte mithilfe eines Skripts automatisch ausführen. Laden Sie in der Befehlszeile mit dem SCRIPT-Befehl die Skriptdatei, und warten Sie, bis dieser abgeschlossen wurde. Wenn Sie mehrere Skripte für verschiedene Darstellungsmodelle ausführen, vergewissern Sie sich, dass Sie immer mit einer leeren Zeichnung beginnen, bevor Sie das Darstellungsmodell öffnen. Andernfalls speichern Sie alte Layer aus der vorhergehenden Zeichnung im neuen Darstellungsmodell.
Im Folgenden sehen Sie ein Beispielskript. Sie können es als Datei mit der Erweiterung .scr speichern.
CMDDIA 0 FILEDIA 0 _TBDMOPEN [path to your TBDM file] _TBGENERATEGRAPHIC _MAPSYMBOLIMPORTEXPORT _IMPORT [choose options that fit your needs] _TBDMSAVEWenn Sie das Skript abgeschlossen haben, setzen Sie die Variablen CMDDIA und FILEDIA zurück auf ihre ursprünglichen Werte, typischerweise '1'.
Zur Zeitersparnis können Sie die Symbole für viele Darstellungsmodelle mithilfe eines VBA-Skripts (Microsoft Visual Basic for Applications) in einem einzigen Vorgang importieren. Das folgende Skript ist ein Beispiel. Sie können es als Vorlage verwenden, die erforderlichen Änderungen vornehmen und es als .bas-Datei speichern.
Attribute VB_Name = "ImportSymbolInto_IM_DM" Sub ImportSymbolIntoDisplayModel() Dim prototypeDWG, templateDWT As String Dim FileDia, CmdDia As Integer Dim displayModelArray(0 To 2) As String 'TODO: Adapt to the number of Display Models to update ' TODO - Adapt to your settings ' Define the path to the Display Models for updating the symbol(s) ' When adding or removing Display Models, please adapt also the size of displayModelArray ' and the loop over all Display Models displayModelArray(0) = "C:\TEST\DM1\DM1.tbdm" displayModelArray(1) = " C:\TEST\DM2\DM2.tbdm" displayModelArray(2) = " C:\TEST\DM3\DM3.tbdm" ' Attention !!! ' Only use the "Generic Graphic" - Application option: Reuse current drawings ' We need the same drawing for all operations ! ' TODO - Adapt to your settings ' Define where the symbol(s) should be imported from prototypeDWG = "C:\temp\symbol_modified.dwg " ' TODO - Adapt to your settings ' Define the template file to be used when open a new DWG templateDWT = "c:\temp\Template\map2d.dwt" 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 FileDia = ThisDrawing.GetVariable("FILEDIA") CmdDia = ThisDrawing.GetVariable("CMDDIA") ThisDrawing.SetVariable "FILEDIA", 0 ThisDrawing.SetVariable "CMDDIA", 0 ' Loop all Display Models For inti = 0 To 2 ' Open an empty drawing Application.Documents.Open (templateDWT) ' Open the Display Model ThisDrawing.SendCommand "_TBDMOPEN" & vbCr & displayModelArray(inti) & vbCr ThisDrawing.SendCommand "_TBGENERATEGRAPHIC" & vbCr ' Import the symbol and apply changes to the layers ThisDrawing.SendCommand "_MAPSYMBOLIMPORTEXPORT" & vbCr & "_IMPORT" & vbCr & prototypeDWG & vbCr & "_YES" & vbCr ' Save the changes of the layers to the Display Model ThisDrawing.SendCommand "_TBDMSAVE" & vbCr ' Do not save the drawing ThisDrawing.Close (False) Next ' Reset the system variables ThisDrawing.SetVariable "FILEDIA", FileDia ThisDrawing.SetVariable "CMDDIA", CmdDia End Sub
Im Beispielskript ist ein Modul, "ImportSymbolInto_IM_DM", mit einem untergeordneten Element, "ImportSymbolIntoDisplayModel ()", vorhanden. Sie müssen die Anzahl der Darstellungsmodelle und die Pfade zur DWT- und zu den .tbdm-Dateien anpassen.
So importieren Sie mithilfe eines VBA-Skripts Symbole für mehrere Darstellungsmodelle
In einer Meldung werden Sie dazu aufgefordert, den Autodesk AutoCAD VBA Enabler herunterzuladen, sofern Sie ihn noch nicht installiert haben.
Wenn das System eine Warnung aufgrund der Makros ausgibt, klicken Sie auf Makros aktivieren.