Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Did any one have idea about the API to get the Allocated Parts from Standard operations.
Note: Allocated parts will be shown in the Process Plan structure of Standard Operations but will not shown in allocated parts tab of Standard Operation.
Solved! Go to Solution.
Hello,
I had the same problem and it took me several days to figure out a solution. I don't know if it is the right way to do it, but it works for me. The function works for both, MPMOperation and MPMStandardOperation and returns a List of MPMOperationToPartLink for the allocated parts.
I hope this will help you.
public static List<MPMOperationToPartLink> getAllocatedParts(MPMOperationHolder mpmOperationHolder, MPMOperation mpmOperation, MPMOperationUsageLink mpmOperationUsageLink, NavigationCriteria navigationCriteria) throws Exception {
List<MPMOperationToPartLink> resultList = new ArrayList<>();
if (mpmOperation instanceof MPMStandardOperation) {
/** Add MPMOperationToPartLink to collection for each part that is allocated to this standard operation */
String operationPath = "/" + mpmOperationUsageLink.getClass().getSimpleName() + ":" + mpmOperationUsageLink.getUniqueIdentifier();
Collection<MPMOperationToPartLink> allocatedPartsToStandardOperation = MPMProcessPlanHelper.service.getAllocatedPartToStandardOperation(mpmOperation, operationPath, navigationCriteria);
for (MPMOperationToPartLink operationToPartLink : allocatedPartsToStandardOperation) {
if ((operationToPartLink.getRoleAObject()).equals(mpmOperationHolder)) {
resultList.add(operationToPartLink);
}
}
} else {
/** Add MPMOperationToPartLink to collection for each part that is allocated to this operation */
QueryResult qrOperationToPartLinks = MPMProcessPlanHelper.service.getMPMOperationToPartLinks(mpmOperation);
while (qrOperationToPartLinks.hasMoreElements()) {
MPMOperationToPartLink mpmOperationToPartLink = (MPMOperationToPartLink) qrOperationToPartLinks.nextElement();
resultList.add(mpmOperationToPartLink);
}
}
return resultList;
}
Hey hbavirisetti ,
Hopefully someone who knows more about the API and MPMLink chimes in, as I'm not familiar with this, but does article,
https://www.ptc.com/en/support/article?n=CS172385
Answer your question? It seems maybe related.
Hi MichaelChatel,
Thanks for the Response.
The suggested Article resolution is working only for MPMOperation Type and not for MPMStandardOperation Type.
Please suggest if you have any idea.
Thanks,
Hemanth Kumar
Hello,
I had the same problem and it took me several days to figure out a solution. I don't know if it is the right way to do it, but it works for me. The function works for both, MPMOperation and MPMStandardOperation and returns a List of MPMOperationToPartLink for the allocated parts.
I hope this will help you.
public static List<MPMOperationToPartLink> getAllocatedParts(MPMOperationHolder mpmOperationHolder, MPMOperation mpmOperation, MPMOperationUsageLink mpmOperationUsageLink, NavigationCriteria navigationCriteria) throws Exception {
List<MPMOperationToPartLink> resultList = new ArrayList<>();
if (mpmOperation instanceof MPMStandardOperation) {
/** Add MPMOperationToPartLink to collection for each part that is allocated to this standard operation */
String operationPath = "/" + mpmOperationUsageLink.getClass().getSimpleName() + ":" + mpmOperationUsageLink.getUniqueIdentifier();
Collection<MPMOperationToPartLink> allocatedPartsToStandardOperation = MPMProcessPlanHelper.service.getAllocatedPartToStandardOperation(mpmOperation, operationPath, navigationCriteria);
for (MPMOperationToPartLink operationToPartLink : allocatedPartsToStandardOperation) {
if ((operationToPartLink.getRoleAObject()).equals(mpmOperationHolder)) {
resultList.add(operationToPartLink);
}
}
} else {
/** Add MPMOperationToPartLink to collection for each part that is allocated to this operation */
QueryResult qrOperationToPartLinks = MPMProcessPlanHelper.service.getMPMOperationToPartLinks(mpmOperation);
while (qrOperationToPartLinks.hasMoreElements()) {
MPMOperationToPartLink mpmOperationToPartLink = (MPMOperationToPartLink) qrOperationToPartLinks.nextElement();
resultList.add(mpmOperationToPartLink);
}
}
return resultList;
}
I tried the same methodology format in last week and it worked me too.
Thanks for the solution.
Regards,
Hemanth Kumar