文件转换宏CATScript

时间:2018-06-04 14:09:55

标签: vba catia

您好我试图让这个宏将CATDrawings转换成DXF。但我认为它过早地终止了。它应该为运行时文件夹中的所有.CATDrawing文件创建一个.dxf填充。任何人都可以帮忙看看有什么不对吗?

Sub CatMain()

    Dim fileSys

    Set fileSys = CATIA.FileSystem

    Dim FolderPath

    FolderPath = InputBox( "Enter a folder path:", "Folder path to convert the drawings" ,sDocPath & "P:\DrawingtoPDF")

    Dim filefolder
    Set filefolder = FileSys.GetFolder(FolderPath)

    Dim i as Integer

    'loop through all files in the folder
     For i = 1 To filefolder.Files.Count
        Dim IFile
        Set IFile = filefolder.Files.Item(i)

        'if the file is a CATDrawing, then open it in CATIA
        If InStr(IFile.Name, ".CATDrawing") <> 0 Then
            Dim Doc
            Set Doc = CATIA.Documents.Open(IFile.Path)
            Set partDocument1 = CATIA.ActiveDocument
            Dim drawingName as String
            drawingName =len(CATIA.ActiveDocument.Name)
            dxfName =left( CATIA.ActiveDocument.Name,drawingName-11)
            'msgbox partt
            PartDocument1.ExportData FolderPath &"\"& dxfName, "dxf"

            'close the open drawing document
            CATIA.ActiveDocument.Close()

        'Skip file not CATDrawing
        ElseIf InStr(IFile.Name, ".CATDrawing") = False Then

            For a = 1 To filefolder.Files.Count
            Set filefolder.Files.Item(a)
            Next 


        End IF
    Next 'go to the next drawing in the folder
End Sub

0 个答案:

没有答案