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

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

SOLVED
Regular Member

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

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

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

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.

 

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

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

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

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

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

Hi sscharmueller,

 

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

 

Thanks for the solution.

 

Regards,

Hemanth Kumar

Announcements
LiveWorx Call For Papers Happening Now!