Your Products have been synced, click here to refresh
Public Class File_Explorer Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim PCDApp, PCDPartProgram, PCDPartPrograms PCDApp = CreateObject("PCDLRN.Application") PCDPartPrograms = PCDApp.PartPrograms 'If PC-DMIS is open, close current program If PCDApp.Visible = True Then PCDPartProgram = PCDApp.ActivePartProgram On Error Resume Next PCDPartProgram.Close() End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If OpenFileDialog1.InitialDirectory = "ORIGINAL FILE DIRECTORY HERE" OpenFileDialog1.Title = "Find your Program" OpenFileDialog1.Filter = ".PRG files|*.prg" OpenFileDialog1.FileName = "" OpenFileDialog1.Multiselect = False If OpenFileDialog1.ShowDialog() = DialogResult.OK Then Dim sourceDir As String = OpenFileDialog1.FileName 'Sets 'sourceDir' to the location of the selected PRG file Dim sourceFileName As String = Dir(sourceDir) 'Extracts PRG file name from path Dim cadDir As String = IO.Path.ChangeExtension(sourceDir, ".CAD") 'Sets 'cadDir' to the location of the selected CAD file Dim cadFileName As String = Dir(cadDir) 'Extracts CAD file name from path Dim destDir As String = IO.Path.Combine("C:\CMM\", sourceFileName) 'Get PRG Destination Path Dim destCADDir As String = IO.Path.Combine("C:\CMM\", cadFileName) 'Get CAD Destination Path 'If the CAD file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destCADDir) Then 'Copy file IO.File.Copy(cadDir, destCADDir) End If 'If the PRG file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destDir) Then 'Copy file IO.File.Copy(sourceDir, destDir) End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If 'Check if both PRG and CAD files exists. If they do, open the PRG. If not, wait 1 sec and loop Do If My.Computer.FileSystem.FileExists(destDir) And My.Computer.FileSystem.FileExists(destCADDir) Then PCDPartPrograms.Open(destDir, "CMM1") Exit Do Else Threading.Thread.Sleep(1000) End If Loop 'Closes the form Me.Close() End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim PCDApp, PCDPartProgram, PCDPartPrograms PCDApp = CreateObject("PCDLRN.Application") PCDPartPrograms = PCDApp.PartPrograms 'If PC-DMIS is open, close current program If PCDApp.Visible = True Then PCDPartProgram = PCDApp.ActivePartProgram On Error Resume Next PCDPartProgram.Close() End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If OpenFileDialog1.InitialDirectory = "ORIGINAL FILE DIRECTORY HERE" OpenFileDialog1.Title = "Find your Program" OpenFileDialog1.Filter = ".PRG files|*.prg" OpenFileDialog1.FileName = "" OpenFileDialog1.Multiselect = False If OpenFileDialog1.ShowDialog() = DialogResult.OK Then Dim sourceDir As String = OpenFileDialog1.FileName 'Sets 'sourceDir' to the location of the selected PRG file Dim sourceFileName As String = Dir(sourceDir) 'Extracts PRG file name from path Dim cadDir As String = IO.Path.ChangeExtension(sourceDir, ".CAD") 'Sets 'cadDir' to the location of the selected CAD file Dim cadFileName As String = Dir(cadDir) 'Extracts CAD file name from path Dim destDir As String = IO.Path.Combine("C:\CMM\", sourceFileName) 'Get PRG Destination Path Dim destCADDir As String = IO.Path.Combine("C:\CMM\", cadFileName) 'Get CAD Destination Path 'If the CAD file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destCADDir) Then 'Copy file IO.File.Copy(cadDir, destCADDir) End If 'If the PRG file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destDir) Then 'Copy file IO.File.Copy(sourceDir, destDir) End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If 'Check if both PRG and CAD files exists. If they do, open the PRG. If not, wait 1 sec and loop Do If My.Computer.FileSystem.FileExists(destDir) And My.Computer.FileSystem.FileExists(destCADDir) Then PCDPartPrograms.Open(destDir, "CMM1") Exit Do Else Threading.Thread.Sleep(1000) End If Loop 'Closes the form Me.Close() End If End Sub End Class
Public Class File_Explorer Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim PCDApp, PCDPartProgram, PCDPartPrograms PCDApp = CreateObject("PCDLRN.Application") PCDPartPrograms = PCDApp.PartPrograms 'If PC-DMIS is open, close current program If PCDApp.Visible = True Then PCDPartProgram = PCDApp.ActivePartProgram On Error Resume Next PCDPartProgram.Close() End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If OpenFileDialog1.InitialDirectory = "ORIGINAL FILE DIRECTORY HERE" OpenFileDialog1.Title = "Find your Program" OpenFileDialog1.Filter = ".PRG files|*.prg" OpenFileDialog1.FileName = "" OpenFileDialog1.Multiselect = False If OpenFileDialog1.ShowDialog() = DialogResult.OK Then Dim sourceDir As String = OpenFileDialog1.FileName 'Sets 'sourceDir' to the location of the selected PRG file Dim sourceFileName As String = Dir(sourceDir) 'Extracts PRG file name from path Dim cadDir As String = IO.Path.ChangeExtension(sourceDir, ".CAD") 'Sets 'cadDir' to the location of the selected CAD file Dim cadFileName As String = Dir(cadDir) 'Extracts CAD file name from path Dim destDir As String = IO.Path.Combine("C:\CMM\", sourceFileName) 'Get PRG Destination Path Dim destCADDir As String = IO.Path.Combine("C:\CMM\", cadFileName) 'Get CAD Destination Path 'If the CAD file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destCADDir) Then 'Copy file IO.File.Copy(cadDir, destCADDir) End If 'If the PRG file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destDir) Then 'Copy file IO.File.Copy(sourceDir, destDir) End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If 'Check if both PRG and CAD files exists. If they do, open the PRG. If not, wait 1 sec and loop Do If My.Computer.FileSystem.FileExists(destDir) And My.Computer.FileSystem.FileExists(destCADDir) Then PCDPartPrograms.Open(destDir, "CMM1") Exit Do Else Threading.Thread.Sleep(1000) End If Loop 'Closes the form Me.Close() End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim PCDApp, PCDPartProgram, PCDPartPrograms PCDApp = CreateObject("PCDLRN.Application") PCDPartPrograms = PCDApp.PartPrograms 'If PC-DMIS is open, close current program If PCDApp.Visible = True Then PCDPartProgram = PCDApp.ActivePartProgram On Error Resume Next PCDPartProgram.Close() End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If OpenFileDialog1.InitialDirectory = "ORIGINAL FILE DIRECTORY HERE" OpenFileDialog1.Title = "Find your Program" OpenFileDialog1.Filter = ".PRG files|*.prg" OpenFileDialog1.FileName = "" OpenFileDialog1.Multiselect = False If OpenFileDialog1.ShowDialog() = DialogResult.OK Then Dim sourceDir As String = OpenFileDialog1.FileName 'Sets 'sourceDir' to the location of the selected PRG file Dim sourceFileName As String = Dir(sourceDir) 'Extracts PRG file name from path Dim cadDir As String = IO.Path.ChangeExtension(sourceDir, ".CAD") 'Sets 'cadDir' to the location of the selected CAD file Dim cadFileName As String = Dir(cadDir) 'Extracts CAD file name from path Dim destDir As String = IO.Path.Combine("C:\CMM\", sourceFileName) 'Get PRG Destination Path Dim destCADDir As String = IO.Path.Combine("C:\CMM\", cadFileName) 'Get CAD Destination Path 'If the CAD file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destCADDir) Then 'Copy file IO.File.Copy(cadDir, destCADDir) End If 'If the PRG file doesn't already exist in new directory, then copy the file If Not My.Computer.FileSystem.FileExists(destDir) Then 'Copy file IO.File.Copy(sourceDir, destDir) End If 'If PC-DMIS is not open, open operator mode If PCDApp.Visible = False Then PCDApp.OperatorMode = True PCDApp.Visible = True End If 'Check if both PRG and CAD files exists. If they do, open the PRG. If not, wait 1 sec and loop Do If My.Computer.FileSystem.FileExists(destDir) And My.Computer.FileSystem.FileExists(destCADDir) Then PCDPartPrograms.Open(destDir, "CMM1") Exit Do Else Threading.Thread.Sleep(1000) End If Loop 'Closes the form Me.Close() End If End Sub End Class
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |