Skip to main content
10-Marble
November 14, 2019
Solved

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

  • November 14, 2019
  • 2 replies
  • 3295 views

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.

Best answer by sscharmueller

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

  

2 replies

5-Regular Member
November 14, 2019

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.

 

10-Marble
November 15, 2019

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

7-Bedrock
November 22, 2019

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

  

10-Marble
November 22, 2019

Hi sscharmueller,

 

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

 

Thanks for the solution.

 

Regards,

Hemanth Kumar