cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

API to get multilevel Where used part?

shindemayur
Aquamarine

API to get multilevel Where used part?

HI,

I want a API to get all levels of where used part, I am using the below API to get where used StructHelper.service.navigateUsedBy(part.getMaster(),true); 

but this gives only 1st level parts. I want all levels as shown in Where Used tab in windchill.

For now I am giving recursive call to the function to get all levels, but this is taking long time, processing time is too high, Is there any better way to do so?

 

@SuppressWarnings("unchecked")
 private   ArrayList<Object> getPartStructure(WTPart part,ArrayList<Object> objectList)
 {
  try
  {  
   ArrayList<WTPart> set=new ArrayList<>();
   QueryResult resultWhere=StructHelper.service.navigateUsedBy(part.getMaster(),true);  
   
   while (resultWhere.hasMoreElements())
   {
    Object object = (Object) resultWhere.nextElement();  
    if(object instanceof WTPart)
    { 
     WTPart prt=(WTPart) object;
     //prt=(WTPart) VersionControlHelper.service.allIterationsOf(prt.getMaster()).nextElement();     
     if(!set.contains(prt))
     {
      set.add(prt);
      if(prt.isEndItem())
      {
       String vehicleFamily=getIBAValue(prt,"VEHICLE_FAMILY");
       if(vehicleFamily!=null && !vehicleFamily.equals(""))
       {
        HashSet<String>familyList=(HashSet<String>)objectList.get(0);
        familyList.add(vehicleFamily);
       }
       else
       {
        HashSet<String>UndisclosedFamilyList=(HashSet<String>)objectList.get(1);
        UndisclosedFamilyList.add(prt.getNumber());
       }
      }else{
      getPartStructure(prt,objectList);
      }
     }
    }
   }   
  }catch (Exception ex)
  {
   ex.printStackTrace();
  }
  return objectList;
 }

3 REPLIES 3

Re: API to get multilevel Where used part?

Hello,

 

You should take a look at wt.part.MultilevelWhereUsedVisitor.

You could also try to see the table builder of the OOTB table

 

 

Florent ROUSSEL
www.4cad.ca

Re: API to get multilevel Where used part?

Thank you @Florent  for reply. I checked MultilevelWhereUsedVisitor and ottb table builder , but it is not understandable. I have a solution has I shared in above post, but I want something with fast response . Actually My requirement is to find the End Part.

Tags (1)

Re: API to get multilevel Where used part?

This may be useful:

 

Windchill APIs to obtain "WTPart" structure in Windchill PDMLink

https://www.ptc.com/en/support/article/CS49806

 

You may want to open a Support case, as our Customization engineers have experience with this.

 

Mike Chatel

 

 

 

Announcements