cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

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

hbavirisetti
10-Marble

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.

ACCEPTED SOLUTION

Accepted Solutions

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

  

View solution in original post

4 REPLIES 4

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

  

Hi sscharmueller,

 

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

 

Thanks for the solution.

 

Regards,

Hemanth Kumar

Announcements

Top Tags