Your Products have been synced, click here to refresh
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.
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |