Your Products have been synced, click here to refresh
To avoid getting myself into this sort of situation I have a text file that contains all of the components of my file paths that I don't have direct control over. I read in this text file at the beginning of every program and use the information to create the paths for saving off data. This way if something like what just happened to you happens to me I can just change a few lines in that text file and all of my programs will adapt to the new directory structure without any modification. This won't be much help to you with your current situation but may be something to consider in the future.
Question: are the paths hard-coded in the File- Printing - Report Window Setup, or are they hard-coded in a Print Command?
By the way N3WPV, do you have any experience scripting in something outside of PC-DMIS (i.e. VB.NET/VBA/VBScript/Powershell/etc.)? If you give us an example of what commands/values you're trying to modify, we could probably help you write something.
PRINT/REPORT,EXEC MODE=END,$ TO_FILE=ON,OVERWRITE="[COLOR=#ff0000]J[/COLOR]:\Quality\Enginetics Part Numbers\5000 - 5999\5307188-01\CMM Reports\5307188-01 - Lot "+ LOT +" - #"+ SERNUM +".rtf",$ TO_PRINTER=OFF,$ TO_DMIS_REPORT=OFF,FILE_OPTION=INDEX,FILENAME=,$ REPORT_THEORETICALS=NONE,REPORT_FEATURE_WITH_DIMENSIONS=NO,$ PREVIOUS_RUNS=KEEP_INSTANCES
Imports System.Threading Imports System.IO Module Module1 Const ProgramDir = "J:\TEMP\" Const ProgramFileExt = "*.PRG" Const ChangeFromPath = "J:\" Const ChangeToPath = "S:\" Private pcdApp As PCDLRN.Application Private pcdParts As PCDLRN.PartPrograms Private pcdActivePart As PCDLRN.PartProgram Private pcdCommands As PCDLRN.Commands Private pcdCommand As PCDLRN.Command Sub Main() If ConnectPCD() = True Then Dim tmpFiles() As String = GetFiles(ProgramDir) Try For Each tmpFile As String In tmpFiles If ConvertPrintPath(tmpFile, ChangeFromPath, ChangeToPath) = False Then Exit For Next Catch ex as Exception Console.Writeline(ex.Message) End Try Console.WriteLine("Complete!") End If DisconnectPCD() Console.ReadLine() End Sub Function GetFiles(ByVal RootDir As String) As String() Return Directory.GetFiles(RootDir, ProgramFileExt, SearchOption.AllDirectories) End Function Function ConnectPCD() As Boolean Try pcdApp = GetObject("", "PCDLRN.Application") pcdApp.WaitUntilReady(60) Thread.Sleep(2000) pcdApp.Visible = True pcdApp.Maximize() pcdParts = pcdApp.PartPrograms If pcdParts.Count <> 0 Then Throw New Exception("Please close all open PC-DMIS part programs.") End If Return True Catch ex As Exception Console.WriteLine("ConnectPCD : " & ex.Message) Return False pcdParts = Nothing pcdApp = Nothing GC.Collect() End Try End Function Sub DisconnectPCD() pcdCommand = Nothing pcdCommands = Nothing pcdActivePart = Nothing pcdParts = Nothing pcdApp = Nothing GC.Collect() End Sub Function ConvertPrintPath(ByVal FilePath As String, ByVal ChangeFrom As String, ByVal ChangeTo As String) As Boolean Console.WriteLine("Converting file: " & FilePath) Try pcdParts.Open(FilePath, "CMM1") pcdActivePart = pcdApp.ActivePartProgram pcdCommands = pcdActivePart.Commands For i As Integer = 0 To pcdCommands.Count pcdCommand = pcdCommands.Item(i) If pcdCommand Is Nothing Then Continue For If Not pcdCommand.Type = PCDLRN.OBTYPE.PRINT_REPORT Then Continue For Dim tmpText = pcdCommand.GetText(PCDLRN.ENUM_FIELD_TYPES.FILE_NAME, 1) If tmpText.Contains(ChangeFrom) Then pcdCommand.PutText(tmpText.Replace(ChangeFrom, ChangeTo), PCDLRN.ENUM_FIELD_TYPES.FILE_NAME, 1) End If Next pcdActivePart.Close() Return True Catch ex As Exception Console.WriteLine("ConvertPrintPath : " & ex.Message) Return False End Try End Function End Module
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |