Skip to main content
Nov 14, 2019 6:08 PM UTC
Solved

API to get the Allocated Parts for "Standard operations"?

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.

Nov 22, 2019 11:16 AM UTC

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;
}

  

4 replies

Nov 14, 2019 8:22 PM UTC

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.

 

Nov 15, 2019 10:31 AM UTC

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

Nov 22, 2019 11:16 AM UTC

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;
}

  

Nov 22, 2019 11:47 AM UTC

Hi sscharmueller,

 

I tried the same methodology format in last week and it worked me too.

 

Thanks for the solution.

 

Regards,

Hemanth Kumar