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.
Solved! Go to Solution.
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
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
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