'------------------------------------------------------------------------------------ '------------------------------------------------------------------------------------ ' Macro created by Thomas Berger, TOBEPLUS November 13, 2009 ' VERSION = V01' ' '------------------------------------------------------------------------------------ ' Dieses Makro sucht in einem angegebenen Verzeichnis alle darin enthaltenen Files auf. ' Von jeder CATDrawing wird ein Exportfile mit User-Format in einem anzugebenden Ordner erstellt. Sub CATMain() 'On Error Resume Next CATIA.DisplayFileAlerts = False Dim Eingabe As String Dim Ausgabe As String Dim Format As String Eingabe = "E:\TEST" Eingabe = InputBox("Bitte geben Sie den Oeffnungs Ort ein.", "CATDrawing to Export-Format Macro - www.tobeplus.de", Eingabe) Ausgabe = "E:\TEST\OUTPUT" Ausgabe = InputBox("Bitte geben Sie den Ausgabeort der Export-Files ein.", "CATDrawing to Export-Format - www.tobeplus.de", Ausgabe) Format = "dxf/dwg/cgm/svg/gl2/ps/catalog/pdf/tif/jpg/ig2/3dxml" Format = InputBox("Bitte geben Sie das Ausgabeformaten an:" & Chr(10) & Chr(10) & "Achtung: evtl. scheitert der Export an fehlenden Lizenzen, bitte nur einen Typ eintippen.", "CATDrawing to Export-Format Macro - www.tobeplus.de", Format) If Format <> "dxf" And Format <> "dwg" And Format <> "cgm" And Format <> "svg" And Format <> "g12" And Format <> "ps" And Format <> "catalog" And Format <> "pdf" And Format <> "tif" And Format <> "jpg" And Format <> "ig2" And Format <> "3dxml" Then Box = MsgBox("Ungueltiges Format, bitte Makro erneut ausführen", vbExclamation, "Falsche Formatangabe - www.tobeplus.de") Exit Sub End If Dim oFileSystem As INFITF.FileSystem 'nur fuer .net Set oFileSystem = CATIA.FileSystem Dim oFolder As INFITF.Folder ' Verzeichnisname fuer CATIA-Daten Set oFolder = oFileSystem.GetFolder(Eingabe) Dim FileSep As String FileSep = oFileSystem.FileSeparator Dim oFile As INFITF.File Dim Datei As String Dim SDatei As String Dim SName As String Dim Pfad As String Pfad = oFolder.Path + FileSep Dim oActiveDoc As document Dim document As document Dim Name As String Dim i As Integer Dim F As Integer F = 0 For i = 1 To oFolder.Files.Count Set oFile = oFolder.Files.Item(i) If Right(oFile.Name, 10) = "CATDrawing" Then Name = Left(oFile.Name, Len(oFile.Name) - 11) Datei = Pfad + Name + ".CATDrawing" F = F + 2 Set oActiveDoc = CATIA.Documents.Open(Datei) Set document = CATIA.ActiveDocument SName = Name + "." + Format SDatei = Ausgabe + FileSep + SName document.ExportData SDatei, Format Datei = "" oActiveDoc.Close End If Next If Err.Number = 0 Then Dim MsgText As String MsgText = "Finished, " & F & " " & Format & " files created in " & Ausgabe & "(counts without details)." Else: MsgText = "Macro Save had errors - Please Check - www.tobeplus.de" End If MsgBox MsgText CATIA.DisplayFileAlerts = True On Error GoTo 0 End Sub