Showing results for 
Search instead for 
Did you mean: 

Advanced Team Center Search

Valued Contributor
Valued Contributor

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
        For Each Item As String In searchResults
            cnt = cnt + 1
            lw.WriteLine(cnt & ".  " & Item)

    End Sub
End Module