Showing results for 
Search instead for 
Do you mean 
Reply

Advanced Team Center Search

Hello, I have some code that I obtained from the NX documentation. I am trying to customize the code so after the search is complete, it won't only display results in a text file, but it will open the results in NX. The other thing is, I need the option to do the search in context of a model structure in NX, so I am not simply pulling up all kinds of randomness from Team Center (like pdf files and such).

 

Thank you.

 

Here is the code:

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.PDM

Module NXJournal
    Sub Main()

        Dim theSession As Session = Session.GetSession()

        Dim myManager As PdmSearchManager = theSession.PdmSearchManager()

        Dim mySearch As PdmSearch
        mySearch = myManager.NewPdmSearch()

        Dim mySearchResult As SearchResult
        mySearchResult = myManager.NewPdmSearchresult()

        ' mySearchResult = mySearch.Simple("*0000*")

        Dim entries() As String = {"object_name"}
        Dim values() As String = {"*xxx-xxxx*"}
        mySearchResult = mySearch.Advanced(entries, values)

        Dim searchResults() As String
        searchResults = mySearchResult.GetResultObjectNames()

        Dim lw As ListingWindow = theSession.ListingWindow
        Dim cnt As Integer = 0
        lw.Open()
        For Each Item As String In searchResults
            cnt = cnt + 1
            lw.WriteLine(cnt & ".  " & Item)
        Next

    End Sub
End Module