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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

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

PK_11615540
2-Explorer

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

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

 

5 REPLIES 5

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 )

 

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;

}

 

@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.

Hi @RaikarRaghu 

Your issue is on a following row Persistable obj = (Persistable) pp.nextElement();

The returned object is not peristable but it is array of pertistable 

 

so try to use 

Persistable persistables[] = (Persistable[]) qr.nextElement();

PetrH

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
Announcements

Top Tags