3 Replies Latest reply on Mar 21, 2013 9:23 AM by Lee CS Young

    Enterprise PDM 2013 API search results

    Giorgos Georgoudakis



      I have written a VB.Net application that searches pdm vault for parts and return some variables to the user.

      This application was developed and worked fine on SolidWorks ePDM 2012.


      But last week we upgraded to 2013 and since then the application has the following problem:


      I am searching for a file on vault which has a variable "partNo" provided by the user and return the results in a listview.


      After the upgrade the listview contains multiple lines of the same file.

      I have figure out that the amount of repeated results of the file is depending on how many configurations this file has.


      ex. A .dxf file which has 3 layers is shown 4 times in my list.

      all .pdf files are shown only 1 time.

      .sldprt files which have 2 configurations is shown 3 times in my list.


      This didnt happend before the upgrade.

      Is there any way to filter results by adding something to search?


      The code used something as simple as that:

      Dim search As IEdmSearch5

      Dim file As IEdmFile5

      search = vault.CreateSearch

      search.AddVariable("PartNo", "%" & PartNo.Text)

      search.FindHistoricStates = False

      Dim result As IEdmSearchResult5

      result = search.GetFirstResult

      While Not result Is Nothing



      ...(populate list)



           result = search.GetNextResult




      While debugging I see that it loops on the exact same file multiple times as i said before.

        • Re: Enterprise PDM 2013 API search results
          Lee CS Young

          I checked quickly and the result you're getting is what I would expect. If your filenames are named the same as your part number you could search using search.Filename. If not, simply filter the results.


          To filter I would do something like this;


          List<IEdmSearchResult5> results = new List<IEdmSearchResult5>();
          IEdmSearchResult5 result = search.GetFirstResult();
          while (result != null)
              result = search.GetNextResult();
          results = results.Distinct(new SearchResultComparer()).ToList();
          class SearchResultComparer : IEqualityComparer<IEdmSearchResult5>
              public bool Equals(IEdmSearchResult5 x, IEdmSearchResult5 y)
                  return x.ID == y.ID;
              public int GetHashCode(IEdmSearchResult5 obj)
                  return obj.ID.GetHashCode();