Hello,
I need to create a link between operation and part with MPMOperationToPartLink. I used the method
com.ptc.windchill.mpml.processplan.operation.MPMOperationToPartLink.newMPMOperationToPartLink(MPMOperation operation, WTPartMaster partMaster)
howeveran error message apears that ComponentIdPath is null.
How to set ComponentIdPath? which parameters in the operation or the part are needed to create such link?
Thank you.
Solved! Go to Solution.
try this :
WTPart child = null;//Allocation part
WTPart parentpart = null;//Parent part
WTPart assemblyPart = null;//Top Assembly part
MPMOperation operation = null;//Operation
WTPartUsageLink parentChildlink = null;//Parent part and Allocation part UsageLink
WTPartUsageLink assemblyParentlink = null;//Top Assembly part and Parent part UsageLink
String componentId = parentChildlink.getComponentId;//Parent part and Allocation part is ComponentID in UsageLink.
String componentIdPath = assemblyParentlink +"|"+componentId ;//Top Assembly part,Parent part and Allocation part is ComponentID in UsageLink. Delimit with a hyphen:demo: XXXXX1|XXXX2
MPMOperationToPartLink link = MPMOperationToPartLink.newMPMOperationToPartLink(operation, (WTPartMaster) child.getMaster());
link.setComponentIdPath(componentIdPath);
link.setComponentId(componentId);
link.setAllocatedPartIterationId(PersistenceHelper.getObjectIdentifier(child).toString());
link.setPartMstrReference(assemblyPart.getMasterReference());
link.setAllocationType(MPMOperationToPartLinkType.CONSUMED);
PersistenceServerHelper.manager.save(link);
try this :
WTPart child = null;//Allocation part
WTPart parentpart = null;//Parent part
WTPart assemblyPart = null;//Top Assembly part
MPMOperation operation = null;//Operation
WTPartUsageLink parentChildlink = null;//Parent part and Allocation part UsageLink
WTPartUsageLink assemblyParentlink = null;//Top Assembly part and Parent part UsageLink
String componentId = parentChildlink.getComponentId;//Parent part and Allocation part is ComponentID in UsageLink.
String componentIdPath = assemblyParentlink +"|"+componentId ;//Top Assembly part,Parent part and Allocation part is ComponentID in UsageLink. Delimit with a hyphen:demo: XXXXX1|XXXX2
MPMOperationToPartLink link = MPMOperationToPartLink.newMPMOperationToPartLink(operation, (WTPartMaster) child.getMaster());
link.setComponentIdPath(componentIdPath);
link.setComponentId(componentId);
link.setAllocatedPartIterationId(PersistenceHelper.getObjectIdentifier(child).toString());
link.setPartMstrReference(assemblyPart.getMasterReference());
link.setAllocationType(MPMOperationToPartLinkType.CONSUMED);
PersistenceServerHelper.manager.save(link);