Skip to main content
1-Visitor
August 16, 2024
Question

is there any api to get only parts which are present in part structure

  • August 16, 2024
  • 2 replies
  • 1326 views

is there any api to get only parts which are present in part structure tab or any other way if api is not present. for reference see the pic attached below.

 

 

 

PK_11615540_0-1723796096173.png

 

2 replies

17-Peridot
August 16, 2024

You need to define a navigation criteria for exact this filter. You have chosen "Latest, Design, Working" then you need to filter the structure with this criteria.

Or you can save this filter and find this navigation criteria based on the user and name.

 

Afterwards you can call the API

Persistable[][][] wt.part.WTPartHelper.service.getUsesWTParts( WTList parts, NavigationCriteria navigationCriteria )

 

12-Amethyst
August 19, 2024

Hello,

I tried with the given solution. it is showing the type cast exception. 

Image is attached

 

This is the code i am using.

 

wt.query.QuerySpec qs = new wt.query.QuerySpec(NavigationCriteria.class);
qs.appendWhere(new SearchCondition(NavigationCriteria.class, NavigationCriteria.SHARED_TO_ALL,
SearchCondition.IS_FALSE), new int[] { 0 });
qs.appendAnd();
qs.appendWhere(new SearchCondition(NavigationCriteria.class, NavigationCriteria.NAME, SearchCondition.EQUAL,
"Test"), new int[] { 0 });
QueryResult qr = PersistenceHelper.manager.find(qs);
System.out.println("Size ************************* " + qr.size());

NavigationCriteria nav = null;
while (qr.hasMoreElements()) {
nav = (NavigationCriteria) qr.nextElement();

System.out.println("Name of NAvigation criteria " + nav.getIdentity() + ",T " + nav.getType() + ",N "
+ nav.getName() + ", A " + nav.getApplicationName());
}

QueryResult pp = wt.part.WTPartHelper.service.getUsesWTParts(part, nav);
System.out.println("PP Size " + pp.size());
while (pp.hasMoreElements()) {
Persistable obj = (Persistable) pp.nextElement();
WTPart pt = (WTPart) obj;

}

 

17-Peridot
August 19, 2024

@RaikarRaghu 

You need to check if it's really a WTPart or a WTPartMaster. Your screenshots shows me, that one part is a master and not a iteration.

Catalina
Community Moderator
August 19, 2024

Hi @PK_11615540,


I wanted to see if you got the help you needed.


If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation.

Thanks,

Catalina | PTC Community Moderator