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
Version: Windchill 13.0
Use Case: want to create multiple usage link in single shot with one time iteration of Parent part
Description:
WTPartUsageLink newUsageLink = WTPartUsageLink.newWTPartUsageLink(parentPart, childPart.getMaster());
this API iterate every time parent part
Hi @AA_9841156
Thank you for your question!
I’d like to recommend to bring more details and context to your initial inquiry.
Please add screenshot(s) to better understand what you are trying to do in your process.
Please refer to this guideline to make your questions more likely to receive a quick and useful answer.
This will increase your chances to receive meaningful help from other Community members.
Furthermore, please consult this Community Search guideline as well, which boosts up your chances of finding a resolution to your topic(s) much faster.
Thank you for your participation and please let me know if you need further assistance!
Best regards,
Checkout Parent
Add UsageLinks
Checkin Parent
Hello @AA_9841156
The point is that the method check-out the Parent for you if it is not check-out. then also does Check-In.
If you need to crate more links, with just one check-out/in then you have to check-out the parent by yourself
In the end of the link creation check-in the parent
// condiftion if object is checkout
UtilWorkInProgress.isCheckedOut((Workable) parrentWTPart);
// example how to checkout and create a link
List<WTPart> checkOutWTPs = new ArrayList<>();
CheckoutLink checkoutLink = UtilWTPart.checkOutObject(parrentWTPart, "check-out", errors);
parrentWTPart = (WTPart) checkoutLink.getWorkingCopy();
checkOutWTPs.add(parrentWTPart);
linkWTP = WTPartUsageLink.newWTPartUsageLink(parrentWTPart, childWTPart.getMaster());
if (linkWTP != null)
{
Quantity qy = Quantity.newQuantity();
qy.setAmount(Double.valueOf(1.0));
qy.setUnit(QuantityUnit.EA);
linkWTP.setQuantity(qy);
//save....
linkWTP = (WTPartUsageLink) PersistenceHelper.manager.store(linkWTP);
}
// do not forget check-in the parent
PetrH