Skip to main content
Jun 2, 2022 5:23 PM UTC
Solved

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.

 

Jun 3, 2022 8:52 AM UTC

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

5 replies

Jun 3, 2022 8:52 AM UTC

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

Jun 3, 2022 10:41 PM UTC

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

 

Jun 6, 2022 6:45 AM UTC

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