cubygt
Aerospace
- Feb 10, 2017
- 10
I have been running into issues with the following CATScript wanting to open and export the same CATDrawing file twice. When this happens it will skip over other files in the folder. Any suggestions is greatly appreciated.
I would also like to have another input box that would allow me to put the converted files in a different folder.
Sub CatMain()
Dim fileSys
Dim filefolder as Object
Dim FolderPath as String
Dim Doc as Document
Dim drawingName as String
Dim IFile as File
Dim i as Integer
Set fileSys = CATIA.FileSystem
FolderPath = InputBox( "Enter a folder path:", "Folder path to convert the drawings" ,sDocPath & "Copy and paste file extension")
Set filefolder = FileSys.GetFolder(FolderPath)
'loop through all files in the folder
For i = 1 To filefolder.Files.Count
Set IFile = filefolder.Files.Item(i)
'open only CATDrawings in CATIA
If InStr(IFile.Name, ".CATDrawing") <> 0 Then
Set Doc = CATIA.Documents.Open(IFile.Path)
Set partDocument1 = CATIA.ActiveDocument
drawingName =len(CATIA.ActiveDocument.Name)
gl2Name =left( CATIA.ActiveDocument.Name,drawingName-11)
'msgbox part
PartDocument1.ExportData FolderPath &"\"& gl2Name, "gl2"
'close the open drawing document
CATIA.ActiveDocument.Close()
End If
Next
End Sub
I would also like to have another input box that would allow me to put the converted files in a different folder.
Sub CatMain()
Dim fileSys
Dim filefolder as Object
Dim FolderPath as String
Dim Doc as Document
Dim drawingName as String
Dim IFile as File
Dim i as Integer
Set fileSys = CATIA.FileSystem
FolderPath = InputBox( "Enter a folder path:", "Folder path to convert the drawings" ,sDocPath & "Copy and paste file extension")
Set filefolder = FileSys.GetFolder(FolderPath)
'loop through all files in the folder
For i = 1 To filefolder.Files.Count
Set IFile = filefolder.Files.Item(i)
'open only CATDrawings in CATIA
If InStr(IFile.Name, ".CATDrawing") <> 0 Then
Set Doc = CATIA.Documents.Open(IFile.Path)
Set partDocument1 = CATIA.ActiveDocument
drawingName =len(CATIA.ActiveDocument.Name)
gl2Name =left( CATIA.ActiveDocument.Name,drawingName-11)
'msgbox part
PartDocument1.ExportData FolderPath &"\"& gl2Name, "gl2"
'close the open drawing document
CATIA.ActiveDocument.Close()
End If
Next
End Sub