home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomctl.ocx"
- Begin VB.Form frmConverter
- Caption = "TurboCAD File Converter"
- ClientHeight = 6645
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 11415
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 6645
- ScaleWidth = 11415
- StartUpPosition = 3 'Windows Default
- Begin MSComctlLib.ProgressBar ProgressBar1
- Height = 345
- Left = 7080
- TabIndex = 20
- Top = 240
- Width = 4095
- _ExtentX = 7223
- _ExtentY = 609
- _Version = 393216
- Appearance = 0
- End
- Begin VB.CommandButton bCancel
- Caption = "Cancel"
- Height = 450
- Left = 4125
- TabIndex = 19
- Top = 5880
- Visible = 0 'False
- Width = 1300
- End
- Begin VB.CommandButton Close
- Caption = "Close"
- Height = 450
- Left = 2055
- TabIndex = 18
- Top = 5880
- Width = 1300
- End
- Begin VB.Timer Timer1
- Enabled = 0 'False
- Interval = 500
- Left = 5535
- Top = 5700
- End
- Begin VB.ComboBox Combo2
- Height = 315
- Left = 6960
- Style = 2 'Dropdown List
- TabIndex = 17
- Top = 5200
- Width = 4215
- End
- Begin VB.ComboBox Combo1
- Height = 315
- ItemData = "Converter.frx":0000
- Left = 1320
- List = "Converter.frx":0002
- MousePointer = 1 'Arrow
- Style = 2 'Dropdown List
- TabIndex = 16
- Top = 5200
- Width = 4215
- End
- Begin VB.DriveListBox Drive2
- Height = 315
- Left = 6000
- TabIndex = 6
- Top = 1080
- Width = 2415
- End
- Begin VB.DirListBox Dir2
- Height = 2565
- Left = 6000
- TabIndex = 5
- ToolTipText = "Select a directory where converted files will be placed."
- Top = 1680
- Width = 2415
- End
- Begin VB.FileListBox File2
- Height = 2625
- Left = 8640
- TabIndex = 4
- Top = 1680
- Width = 2415
- End
- Begin VB.FileListBox File1
- Height = 2625
- Left = 3000
- MultiSelect = 2 'Extended
- TabIndex = 3
- ToolTipText = "A list of files to be converted."
- Top = 1680
- Width = 2415
- End
- Begin VB.DirListBox Dir1
- Height = 2565
- Left = 360
- TabIndex = 2
- ToolTipText = "Select a directory containing files for conversion."
- Top = 1680
- Width = 2415
- End
- Begin VB.DriveListBox Drive1
- Height = 315
- Left = 360
- TabIndex = 1
- Top = 1080
- Width = 2415
- End
- Begin VB.CommandButton Run
- Caption = "Run"
- Height = 450
- Left = 105
- TabIndex = 0
- ToolTipText = "Starts the conversion process."
- Top = 5880
- Width = 1300
- End
- Begin VB.Frame Source
- Caption = "Source:"
- Height = 4215
- Left = 120
- TabIndex = 7
- Top = 720
- Width = 5415
- Begin VB.Label NFiles1
- Height = 375
- Left = 3960
- TabIndex = 11
- Top = 3720
- Width = 1215
- End
- Begin VB.Label Label1
- Caption = "Total files:"
- Height = 375
- Left = 2880
- TabIndex = 8
- Top = 3720
- Width = 855
- End
- End
- Begin VB.Frame Target
- Caption = "Destination:"
- Height = 4215
- Left = 5760
- TabIndex = 9
- Top = 720
- Width = 5415
- Begin VB.Label NFiles2
- Height = 375
- Left = 4080
- TabIndex = 12
- Top = 3720
- Width = 1215
- End
- Begin VB.Label Label2
- Caption = "Total files: "
- Height = 375
- Left = 2880
- TabIndex = 10
- Top = 3720
- Width = 855
- End
- End
- Begin VB.Label ExportFiltersList
- Caption = "Files of type:"
- Height = 375
- Left = 5760
- TabIndex = 15
- Top = 5200
- Width = 975
- End
- Begin VB.Label ImportFiltersList
- Caption = "Files of type:"
- Height = 375
- Left = 120
- TabIndex = 14
- Top = 5200
- Width = 975
- End
- Begin VB.Label Label3
- BorderStyle = 1 'Fixed Single
- Height = 345
- Left = 3000
- TabIndex = 13
- Top = 240
- Width = 3975
- End
- Attribute VB_Name = "frmConverter"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub File1_PatternChange()
- File1.Refresh
- End Sub
- Private Sub File2_PatternChange()
- File2.Refresh
- End Sub
- Private Sub Close_Click()
- Unload frmConverter
- Set Drs = Nothing
- End Sub
- Private Sub Combo1_LostFocus()
- Timer1.Enabled = False
- File1.Pattern = "*." & Left(Combo1.Text, 3)
- File1.Refresh
- NFiles1.Caption = File1.ListCount
- End Sub
- Private Sub Combo1_GotFocus()
- CurCombo = True
- Timer1.Enabled = True
- CurImportFilter = Combo1.Text
- End Sub
- Private Sub Combo2_LostFocus()
- Timer1.Enabled = False
- File2.Pattern = "*." & Left(Combo2.Text, 3)
- File2.Refresh
- NFiles2.Caption = File2.ListCount
- End Sub
- Private Sub Combo2_GotFocus()
- CurCombo = False
- Timer1.Enabled = True
- CurExportFilter = Combo2.Text
- End Sub
- Private Sub Dir1_Change()
- File1.FileName = Dir1.Path
- File1.Refresh
- NFiles1.Caption = File1.ListCount
- End Sub
- Private Sub Dir2_Change()
- File2.FileName = Dir2.Path
- File2.Refresh
- NFiles2.Caption = File2.ListCount
- End Sub
- Private Sub Drive1_Change()
- ' MsgBox Dir1.Path
- On Error GoTo ErrHandler
- Err.Clear
- Dir1.Path = Drive1.Drive
- Dir1.Refresh
- File1.FileName = Dir1.Path
- File1.Refresh
- NFiles1.Caption = File1.ListCount
- Exit Sub
- ErrHandler:
- MsgBox Err.Description, vbOKOnly, LoadResString(101)
- Drive1.Refresh
- Dir1.Path = Drive1.Drive
- Dir1.Refresh
- File1.FileName = Dir1.Path
- File1.Refresh
- NFiles1.Caption = File1.ListCount
- Err.Clear
- End Sub
- Private Sub Drive2_Change()
- ' MsgBox Dir1.Path
- On Error GoTo ErrHandler
- Err.Clear
- Dir2.Path = Drive2.Drive
- Dir2.Refresh
- File2.FileName = Dir2.Path
- File2.Refresh
- NFiles2.Caption = File2.ListCount
- Exit Sub
- ErrHandler:
- MsgBox Err.Description, vbOKOnly, LoadResString(101)
- Drive2.Refresh
- Dir2.Path = Drive2.Drive
- Dir2.Refresh
- File2.FileName = Dir2.Path
- File2.Refresh
- NFiles2.Caption = File2.ListCount
- Err.Clear
- End Sub
- Private Sub Form_Load()
- bConversionRunned = False
- Call Init_ReadFiltersList
- File1.Refresh
- Call Init_WriteFiltersList
- File2.Refresh
- End Sub
- Private Sub Run_Click()
- On Error GoTo ErrorHandler
- Dim CadFile As String
- Dim CadFileSave As String
- Dim temp As String
- Dim ext As String
- Dim bSave As Boolean
- Dim nFilestobeConverted As Integer
- Dim bwasOpened As Boolean
- bwasOpened = False
- Dim lDrIndex As Long
- lDrIndex = -1
- bSave = False
- ext = Left((Right(Combo1.Text, 4)), 3)
- Dim i, iFilesCount As Integer
- i = 0
- iFilesCount = File1.ListCount
- If (iFilesCount = 0) Then
- ' MsgBox "No " & ext & " files in source directory", vbOKOnly, "TurboCAD File Converter"
- MsgBox LoadResString(111) & ext & LoadResString(112), vbOKOnly, LoadResString(101)
- Exit Sub
- End If
- frmConverter.Close.Enabled = False
- bConversionRunned = True
- frmConverter.Run.Enabled = False
- nFilestobeConverted = CheckSourceFileList()
- If (nFilestobeConverted > 0) Then
- ' if at least one file is selected i the files list then perform conversion
- 'setup progress indicator
- ProgressBar1.Min = 0
- ProgressBar1.Max = nFilestobeConverted
- ProgressBar1.Value = 0
- ProgressBar1.Visible = True
- Else
- MsgBox LoadResString(110), vbOKOnly, LoadResString(101)
- Call EnableButtons
- Exit Sub
- End If
- i = 0
- While (i < iFilesCount)
- If (File1.Selected(i) = True) Then
- Label3.Caption = File1.List(i) + LoadResString(114)
- Label3.Refresh
-
- temp = Right(File1.Path, 1)
- If (temp = "\") Then
- CadFile = File1.Path & File1.List(i)
- Else
- CadFile = File1.Path & "\" & File1.List(i)
- End If
-
- On Error Resume Next
- Err.Clear
- For Each Dr In Drs
- If (Dr.Path <> "") Then
- If (Dr.Path = CadFile) Then
- bwasOpened = True
- lDrIndex = Dr.Index
- Exit For
- End If
- End If
- Set Dr = Nothing
- Next Dr
- If bwasOpened And lDrIndex <> -1 Then
- Set Dr = Drs(lDrIndex)
- Else
- Set Dr = Drs.Open(CadFile)
- End If
- If Err.Number <> 0 Then
- Err.Clear
- GoTo NextFile
- End If
-
- temp = Right(File2.Path, 1)
-
- CadFileSave = Left(File1.List(i), (Len(File1.List(i)) - 4)) ' clip the extesion of the file
- If (temp = "\") Then
- CadFileSave = File2.Path & CadFileSave & "." & Left(Combo2.Text, 3) ')Left((Right(Combo2.Text, 5)), 4)
- Else
- CadFileSave = File2.Path & "\" & CadFileSave & "." & Left(Combo2.Text, 3) 'Left((Right(Combo2.Text, 5)), 4)
- End If
-
- ' Dr.SaveAs (CadFileSave)
- ' check drawing for duplicates IDs and correct if necessary
- Call CorrectIDs(Dr)
-
- Dr.SaveCopyAs (CadFileSave)
- If Not bwasOpened Then
- Dr.Close bSave
- End If
- ProgressBar1.Value = ProgressBar1.Value + 1
- NextFile:
- Set Dr = Nothing
- File2.Refresh
- NFiles2.Caption = File2.ListCount
- NFiles2.Refresh
- End If
- i = i + 1
- Wend
- ProgressBar1.Value = 0
- ProgressBar1.Visible = False
- ' MsgBox "Conversion is complete !", vbOKOnly, "TurboCAD file converter"
- MsgBox LoadResString(116), vbOKOnly, LoadResString(101)
- Label3.Caption = ""
- Label3.Refresh
- frmConverter.Close.Enabled = True
- bConversionRunned = False
- frmConverter.Run.Enabled = True
- Exit Sub
- ErrorHandler:
- MsgBox Err.Description, , vbOKOnly, LoadResString(101)
- frmConverter.Close.Enabled = True
- bConversionRunned = False
- frmConverter.Run.Enabled = True
- ProgressBar1.Value = 0
- ProgressBar1.Visible = False
- End Sub
- Sub Timer1_Timer()
- If (CurCombo = True) Then
- If (CurImportFilter <> Combo1.Text) Then
- File1.Pattern = "*." & Left(Combo1.Text, 3)
- File1.Refresh
- NFiles1.Caption = File1.ListCount
- End If
- Else
- If (CurExportFilter <> Combo2.Text) Then
- File2.Pattern = "*." & Left(Combo2.Text, 3)
- File2.Refresh
- NFiles2.Caption = File2.ListCount
- End If
- End If
- End Sub
- Public Sub Init_ReadFiltersList()
- Dim n As Long
- Dim Ft As Filter
- Dim FtName As String
- Dim i As Long
- i = 0
- Set Ftrs = ObjApp.Filters
- n = Ftrs.Count
- Combo1.Clear
- 'Fill list of filters that TurboCAD can import
- While (i < n)
- Set Ft = Ftrs.Item(i)
- If (Ft.Capability = imsiRead Or Ft.Capability = imsiReadWrite) Then
- If (Ft.Hidden = False) Then
- ' skip bmf filter because it works via FP Bridge now
- If (Ft.Extension <> "BMF") Then
- FtName = Ft.FilterString
- FtName = Left(FtName, (Len(FtName) - 8))
- Combo1.AddItem Ft.Extension & " " & " - " & Ft.Description
- End If
- End If
- End If
- Set Ft = Nothing
- i = i + 1
- Combo1.ListIndex = 0
- File1.Pattern = "*." & Left(Combo1.Text, 3)
- File1.Refresh
- NFiles1.Caption = File1.ListCount
- Combo1.Refresh
- End Sub
- Public Sub Init_WriteFiltersList()
- Dim n As Long
- Dim Ft As Filter
- Dim FtName As String
- Dim i As Long
- i = 0
- Set Ftrs = ObjApp.Filters
- n = Ftrs.Count
- Combo2.Clear
- 'Fill list of filters that TurboCAD can export to
- While (i < n)
- Set Ft = Ftrs.Item(i)
- If (Ft.Capability = imsiWrite Or Ft.Capability = imsiReadWrite) Then
- If (Ft.Hidden = False) Then
- If (Ft.Extension(0) <> "BMF") Then
- FtName = Ft.FilterString
- FtName = Left(FtName, (Len(FtName) - 8))
- Combo2.AddItem Ft.Extension & " " & " - " & Ft.Description
- End If
- End If
- End If
- Set Ft = Nothing
- i = i + 1
- Combo2.ListIndex = 1
- File2.Pattern = "*." & Left(Combo2.Text, 3)
- File2.Refresh
- NFiles2.Caption = File2.ListCount
- Combo2.Refresh
- End Sub
- Private Function CheckSourceFileList() As Integer
- Dim i As Integer
- Dim n As Integer
- Dim k As Integer
- k = 0
- i = 0
- n = File1.ListCount
- CheckSourceFileList = 0
- While (i < n)
- If (File1.Selected(i) = True) Then
- k = k + 1
- End If
- i = i + 1
- Wend
- CheckSourceFileList = k
- End Function
- Private Sub EnableButtons()
- frmConverter.Close.Enabled = True
- bConversionRunned = False
- frmConverter.Run.Enabled = True
- End Sub
-