pAddedHuman为被复制的Product Reference,pDuplactedHuman为新复制的Product Reference。
CATAdpDuplicator duplicator;
CATIPLMComponent_var spComponent = pAddedHuman;
ReleaseInterface(pAddedHuman);
CATIAdpPLMIdentificator *pAddedHumanId = NULL;
spComponent -> GetAdpID(pAddedHumanId);
hr = duplicator.AddElement(pAddedHumanId);
CATAdpComponentsAssociation association;
hr = duplicator.Duplicate(association);
CATIAdpPLMIdentificator *pDuplicated = NULL;
CATAdpOpener adpOpener(Bag);
CATIPLMProducts *pDuplactedHuman = NULL;
if(S_OK == association.GetAssociated(pAddedHumanId, pDuplicated))
{
hr=adpOpener.CompleteAndOpen(pDuplicated,IID_CATIPLMProducts,(void**)&pDuplactedHuman);
if(hr != S_OK){
::MessageBoxString("复制引用失败!");
return;
}
}
ReleaseInterface(pDuplicated);
ReleaseInterface(pAddedHumanId);