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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Getting Usage link attrubutes API

WM_9965332
11-Garnet

Getting Usage link attrubutes API

Is there an API  to retrieve the uses attributes in the part structure for WTPart? 

Attributes such as Line Number, Quantity, Unit, Trace Code, Reference Designator, Find Number.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @WM_9965332 

You can use something like this:

 

QueryResult qResult = WTPartHelper.service.getUsesWTParts(primWtp, new LatestConfigSpec());

while
(qResult.hasMoreElements())
{
Object[] obj = (Object[]) qResult.nextElement();
WTPartUsageLink link = (WTPartUsageLink) obj[0];
WTPart subWTP = (WTPart) obj[1];

long lineNumber = link.getLineNumber().getValue();
double amount = link.getQuantity().getAmount();
String unit =
link.getQuantity().getUnit().getStringValue();
String traceCode = link.getTraceCode().getStringValue();

}

PetrH

View solution in original post

5 REPLIES 5

Hi @WM_9965332 

You can use something like this:

 

QueryResult qResult = WTPartHelper.service.getUsesWTParts(primWtp, new LatestConfigSpec());

while
(qResult.hasMoreElements())
{
Object[] obj = (Object[]) qResult.nextElement();
WTPartUsageLink link = (WTPartUsageLink) obj[0];
WTPart subWTP = (WTPart) obj[1];

long lineNumber = link.getLineNumber().getValue();
double amount = link.getQuantity().getAmount();
String unit =
link.getQuantity().getUnit().getStringValue();
String traceCode = link.getTraceCode().getStringValue();

}

PetrH

Thank you! Is there a way of getting the enumerated display value? 

For instance, for unit I'm getting wt.part.QuantityUnit.ea instead of ea (each). And for tracecode I'm getting wt.configuration.TraceCode.0 instead of Untraced

 

Hi @WM_9965332 

 

If you use IDE to write code, you should find the methods you need.

 

HelesicPetr_2-1654497849554.png

 

HelesicPetr_0-1654497806433.png

 

PetrH

 

Awesome! It worked for me, thanks! Is there an api to fetch reference designator? I don't see that in the api list but it is a usage link attribute

Hi @WM_9965332 

Actually direct method does not exists.

So you need to use PersistableAdapter. (don't ask why :D)

 

PersistableAdapter paObject = new PersistableAdapter(link, null, null, null);
paObject.load("referenceDesignatorRange");
Object referenceDesign = paObject.get("referenceDesignatorRange");

 The object is value of reference designator but I do not try to check if it is String or other Java Object. It is up to you >D.

 

Hope this help you

 

The information is in Article cs47438

 

PetrH

Top Tags