hexagon logo

Has anyone made a script to list all used probes (tips) in all programs?

Has anyone made a script to list all used probes (tips) in all programs (in a certain folder)? Technically it should be possible - get a list of all programs, open them one after another, scan for LOADPROBE and TIP commands, collect data.

But has anyone already done it? And is able to share?
  • Not really. All that does is scan all programs and add tips to the current probe file. Has to be redone for each probe file, and still doesn't tell me which part program uses which probe file.

    My wish is rather a report; list all probe files, list all tips in each file, and all part programs using this probe file/tip. With the alternative report listing all part programs, and for each of them list which probe files and tips are used.
  • Have your colleagues release the fileformat specification for the .PRG files and you'll see that a myriad of useful apps will emerge... Rolling eyes

    I guess a filesearch for "L.O.A.D.P.R.B" "could" work, provided that the PRG is saved using english?
  • ... the fileformat specification for the .PRG files ...


    I don't think that exists in any other form than the code that does load/save...
  • I have a vb.net program that lists all the probes in an open program. Then you can select on the form whether to view all probes/angles, or only unique probes/angles. I stripped some of the code out to see if you can adapt it. You'll need to write the section to iterate through the files. Side note: I export a copy of the text for every program when it is ran. Then I can scan through the text files very quickly for anything specific instead of opening and closing hundreds of programs.

    You'll want to change the "write out results" section at the end to fit your needs.

    See if this helps any:
    Imports System.Text
    
    Module Module1
        Sub FindAll()
            Dim Pcd_app As PCDLRN.Application = New PCDLRN.Application
            Dim lstProbesAngles As New List(Of String)
            Dim strUniqueProbes As New StringBuilder
            Dim strAllProbes As New StringBuilder
            Dim ds As New DataSet
            Dim count As Integer = 0
            Dim sProbe As String
            Dim sAngle As String
            Dim bDupe As Boolean = False
            Dim strProgramText As String = Pcd_app.ActivePartProgram.EditWindowTextAll 'get program text
            Dim splCMDs() As String = Split(strProgramText, Chr(10)) 'split text lines into array
    
            strAllProbes.AppendLine("Tip/Angle".PadRight(24) & "Line#")
            strAllProbes.AppendLine("-".PadRight(30, "-"))
    
            strUniqueProbes.AppendLine("Tip/Angle".PadRight(24) & "Line#")
            strUniqueProbes.AppendLine("-".PadRight(30, "-"))
    
            For Each s In splCMDs 'iterate through each line
                Dim str As String = ""
                count += 1
                If s.Contains("LOADPROBE") Then 'if new probe
                    Dim spl() As String = s.Split("/")
                    sProbe = spl(1).Trim
                    'create new table for probe if it doesn't already exist
                    If Not ds.Tables.Contains(sProbe) Then
                        ds.Tables.Add(sProbe)
                        With ds.Tables(sProbe)
                            .Columns.Add("Angle")
                            .Columns.Add("Line")
                            Dim keyColumn(1) As DataColumn
                            keyColumn(0) = .Columns(0)
                            ds.Tables(sProbe).PrimaryKey = keyColumn
                        End With
                        strAllProbes.AppendLine(sProbe.PadRight(24) & count) 'add to full probe list
                    Else
                        strAllProbes.AppendLine("*" & sProbe.PadRight(23) & count) 'add to full probe list with * to indicate duplicate
                    End If
                ElseIf s.Contains("TIP/") Then 'probe angle
                    Dim spl() As String = s.Split("/")
                    sAngle = Strings.Left(spl(1).Trim, InStr(spl(1).Trim, ",") - 1) 'get tip name
                    'try to add to table, if error returned, then tip is already in table.
                    Try
                        ds.Tables(sProbe).Rows.Add({sAngle, count})
                    Catch ex As Exception
                        Console.WriteLine(sProbe & " - " & ex.Message)
                        bDupe = True
                    End Try
                    'if duplicate tip, add to list with * 
                    If bDupe Then
                        strAllProbes.AppendLine("   *" & sAngle.PadRight(20) & count)
                        bDupe = False
                    Else
                        strAllProbes.AppendLine("    " & sAngle.PadRight(20) & count)
                    End If
    
                End If
            Next
    
            'convert table to string builder object
            For Each t As DataTable In ds.Tables
                t.DefaultView.Sort = "Angle" & " DESC"
                strUniqueProbes.AppendLine(t.TableName)
                For Each r As DataRow In t.Rows
                    strUniqueProbes.AppendLine("    " & r(0).ToString.PadRight(20) & r(1))
                Next
            Next
    
            'write out results
            Console.WriteLine("--Unique Probes--")
            Console.WriteLine(strUniqueProbes.ToString)
            Console.WriteLine("")
            Console.WriteLine("")
            Console.WriteLine("--All Probes--")
            Console.WriteLine(strAllProbes.ToString)
    
            Pcd_app = Nothing
        End Sub
    End Module
  • Then I can scan through the text files very quickly for anything specific instead of opening and closing hundreds of programs.


    This is the reason for me asking for the fileformat of the PRG files, that way we can write our own parser for anything .PRG-related. I have found out that (many of) the PC-DMIS files (.PRG) are a flavour of the object compound document format (Microsoft). The EULA is forcing us to wait (indefinitely?) for a fileformat specification release (don't hold your breath) though...
  • That would sure be convenient. I'd also like to be able to parse through the probe files...so much I could do with that!
  • @bjacobson: Thanks for the code! Will experiment when time allows, and let you all know the results...

    @vpt: I don't think the file formats will ever be public. And I'm not sure it would be a good idea, as it would lock the file formats, instead of letting them change it as needed when needed. We are at least happy enough to have the automation interfaces to 'everything', there are other software products that are much more closed.
  • Andersl, did you ever make headway on this request? I've just moved into a role with a company that's been running a muck for years.
    They currently have every index for every probe on every (14 total!) machine. This is literally days worth of needless qualification time!
    So were you ever able to compile some code (or other solution) to extract your used probe index? Thanks so much for any insight!